summaryrefslogtreecommitdiff
path: root/django/utils/cache.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-03-02 12:47:36 +0000
committerJannis Leidel <jannis@leidel.info>2011-03-02 12:47:36 +0000
commitf6c991667f6f1ab8d2fd2afc1ee2b5801e78b7e3 (patch)
tree0fcdcbff97c5fe84098321b9af11b0568a9a6661 /django/utils/cache.py
parenta9ace1466d0a57a020fd1318378df474352ba27a (diff)
Fixed #4992 -- Respect the GET request query string when creating cache keys. Thanks PeterKz and guettli for the initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15705 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/cache.py')
-rw-r--r--django/utils/cache.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/django/utils/cache.py b/django/utils/cache.py
index 4b3b5af04c..63c4af3494 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -160,24 +160,24 @@ def _generate_cache_key(request, method, headerlist, key_prefix):
value = request.META.get(header, None)
if value is not None:
ctx.update(value)
- path = md5_constructor(iri_to_uri(request.path))
+ path = md5_constructor(iri_to_uri(request.get_full_path()))
cache_key = 'views.decorators.cache.cache_page.%s.%s.%s.%s' % (
key_prefix, request.method, path.hexdigest(), ctx.hexdigest())
return _i18n_cache_key_suffix(request, cache_key)
def _generate_cache_header_key(key_prefix, request):
"""Returns a cache key for the header cache."""
- path = md5_constructor(iri_to_uri(request.path))
+ path = md5_constructor(iri_to_uri(request.get_full_path()))
cache_key = 'views.decorators.cache.cache_header.%s.%s' % (
key_prefix, path.hexdigest())
return _i18n_cache_key_suffix(request, cache_key)
def get_cache_key(request, key_prefix=None, method='GET', cache=None):
"""
- Returns a cache key based on the request path. It can be used in the
- request phase because it pulls the list of headers to take into account
- from the global path registry and uses those to build a cache key to check
- against.
+ Returns a cache key based on the request path and query. It can be used
+ in the request phase because it pulls the list of headers to take into
+ account from the global path registry and uses those to build a cache key
+ to check against.
If there is no headerlist stored, the page needs to be rebuilt, so this
function returns None.
@@ -220,7 +220,7 @@ def learn_cache_key(request, response, cache_timeout=None, key_prefix=None, cach
return _generate_cache_key(request, request.method, headerlist, key_prefix)
else:
# if there is no Vary header, we still need a cache key
- # for the request.path
+ # for the request.get_full_path()
cache.set(cache_key, [], cache_timeout)
return _generate_cache_key(request, request.method, [], key_prefix)