summaryrefslogtreecommitdiff
path: root/django/middleware/cache.py
diff options
context:
space:
mode:
authorRinat Khabibiev <srenskiy@gmail.com>2016-09-12 17:19:36 +0300
committerTim Graham <timograham@gmail.com>2016-09-14 19:37:18 -0400
commitf9702977b72003c17db87d6e4fdaa36415f13a38 (patch)
tree8fd57ca3176ba2e5427e59210877eef4ba70c10b /django/middleware/cache.py
parent9459ec82aa12cad9b859c54c2f33f50bec057f2e (diff)
Fixed #27211 -- Made UpdateCacheMiddleware include caching headers for "304 Not Modified" responses.
Diffstat (limited to 'django/middleware/cache.py')
-rw-r--r--django/middleware/cache.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/middleware/cache.py b/django/middleware/cache.py
index 8ee3f514e8..a4dde10dc4 100644
--- a/django/middleware/cache.py
+++ b/django/middleware/cache.py
@@ -77,7 +77,7 @@ class UpdateCacheMiddleware(MiddlewareMixin):
# We don't need to update the cache, just return.
return response
- if response.streaming or response.status_code != 200:
+ if response.streaming or response.status_code not in (200, 304):
return response
# Don't cache responses that set a user-specific (and maybe security
@@ -95,7 +95,7 @@ class UpdateCacheMiddleware(MiddlewareMixin):
# max-age was set to 0, don't bother caching.
return response
patch_response_headers(response, timeout)
- if timeout:
+ if timeout and response.status_code == 200:
cache_key = learn_cache_key(request, response, timeout, self.key_prefix, cache=self.cache)
if hasattr(response, 'render') and callable(response.render):
response.add_post_render_callback(