Skip to content

Commit 642f1c0

Browse files
authored
Merge pull request #183 from sk1p/fix_no_store
Fix behaviour of Cache-Control: no-store on responses
2 parents f3fa83c + 79d0802 commit 642f1c0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cachecontrol/controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ def cache_response(self, request, response, body=None,
290290
if no_store and self.cache.get(cache_url):
291291
logger.debug('Purging existing cache entry to honor "no-store"')
292292
self.cache.delete(cache_url)
293+
if no_store:
294+
return
293295

294296
# If we've been given an etag, then keep the response
295297
if self.cache_etags and 'etag' in response_headers:

tests/test_cache_control.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def test_cache_response_no_store(self):
115115
cc.cache_response(self.req(), resp)
116116
assert not cc.cache.get(cache_url)
117117

118+
def test_cache_response_no_store_with_etag(self, cc):
119+
resp = self.resp({'cache-control': 'no-store', 'ETag': 'jfd9094r808'})
120+
cc.cache_response(self.req(), resp)
121+
122+
assert not cc.cache.set.called
123+
118124
def test_update_cached_response_with_valid_headers(self):
119125
cached_resp = Mock(headers={'ETag': 'jfd9094r808', 'Content-Length': 100})
120126

0 commit comments

Comments
 (0)