diff options
| author | ijl <uijllji@gmail.com> | 2013-12-26 23:14:08 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-12-28 11:20:18 -0500 |
| commit | 71a03e01aa19cbde08e915d156abf39b67d904ef (patch) | |
| tree | 3de922c8a4f4214606323d841e75e27aadccdb33 /docs/topics | |
| parent | 280c1a65ccacd679bf298bf2b169ff01e7266b8e (diff) | |
Fixed #20346 -- Made cache middleware vary on the full URL.
Previously, only the URL path was included in the cache key.
Thanks jamey for the suggestion.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/cache.txt | 8 |
1 files changed, 7 insertions, 1 deletions
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:: |
