summaryrefslogtreecommitdiff
path: root/django/utils/cache.py
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2011-02-01 00:31:34 +0000
committerCarl Meyer <carl@oddbird.net>2011-02-01 00:31:34 +0000
commitcda07b4cfaf92fe82f58d3d6ca6e64ea40502b0d (patch)
tree714374d0e865536d800a04db6b8f07466cfad9d3 /django/utils/cache.py
parent432ff76035efafba73a81bab5b0c12482acdb1fe (diff)
[1.2.X] Fixed #13283 -- Corrected CACHE_MIDDLEWARE_ANONYMOUS_ONLY's bad habit of setting Vary: Cookie on all responses and destroying cache efficiency. Thanks to natrius for the fix.
Backport of r15381 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15382 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/cache.py')
-rw-r--r--django/utils/cache.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/django/utils/cache.py b/django/utils/cache.py
index 6cfd893668..58d087b079 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -134,6 +134,16 @@ def patch_vary_headers(response, newheaders):
if newheader.lower() not in existing_headers]
response['Vary'] = ', '.join(vary_headers + additional_headers)
+def has_vary_header(response, header_query):
+ """
+ Checks to see if the response has a given header name in its Vary header.
+ """
+ if not response.has_header('Vary'):
+ return False
+ vary_headers = cc_delim_re.split(response['Vary'])
+ existing_headers = set([header.lower() for header in vary_headers])
+ return header_query.lower() in existing_headers
+
def _i18n_cache_key_suffix(request, cache_key):
"""If enabled, returns the cache key ending with a locale."""
if settings.USE_I18N: