diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.7.txt | 13 | ||||
| -rw-r--r-- | docs/topics/cache.txt | 8 |
2 files changed, 20 insertions, 1 deletions
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 2c3e3f217d..dbbdcf9c81 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -622,6 +622,19 @@ cache-specific errors. This has been fixed in Django 1.7, see .. _Ticket #21200: https://code.djangoproject.com/ticket/21200 +Cache keys are now generated from the request's absolute URL +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Previous versions of Django generated cache keys using a request's path and +query string but not the scheme or host. If a Django application was serving +multiple subdomains or domains, cache keys could collide. In Django 1.7, cache +keys vary by the absolute URL of the request including scheme, host, path, and +query string. For example, the URL portion of a cache key is now generated from +``http://www.example.com/path/to/?key=val`` rather than ``/path/to/?key=val``. +The cache keys generated by Django 1.7 will be different from the keys +generated by older versions of Django. After upgrading to Django 1.7, the first +request to any previously cached URL will be a cache miss . + Passing ``None`` to ``Manager.db_manager()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index 7ef7285fb7..5fc352f4ec 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -1046,13 +1046,19 @@ the contents of a Web page depend on a user's language preference, the page is said to "vary on language." By default, Django's cache system creates its cache keys using the requested -path and query -- e.g., ``"/stories/2005/?order_by=author"``. This means every +fully-qualified URL -- e.g., +``"http://www.example.com/stories/2005/?order_by=author"``. This means every request to that URL will use the same cached version, regardless of user-agent differences such as cookies or language preferences. However, if this page produces different content based on some difference in request headers -- such as a cookie, or a language, or a user-agent -- you'll need to use the ``Vary`` header to tell caching mechanisms that the page output depends on those things. + .. versionchanged:: 1.7 + + Cache keys use the request's fully-qualified URL rather than path + and query string. + To do this in Django, use the convenient :func:`django.views.decorators.vary.vary_on_headers` view decorator, like so:: |
