summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-07-01 17:32:14 -0400
committerTim Graham <timograham@gmail.com>2014-07-01 17:34:24 -0400
commite125984394eaca8be82ed6f1ad10075ecd13e806 (patch)
tree688c4863e1596149303ec09661c8a6ee40e71f6d /docs/ref
parent6883602021bb9ad681bfc5f01fcc08163add60e0 (diff)
[1.6.x] Fixed #13755 -- Added a tip for caching responses that vary on AJAX.
Thanks mila for the suggestion. Backport of db9a1a0c47 from master
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/request-response.txt7
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
index 4ad451a325..cc2e2c088e 100644
--- a/docs/ref/request-response.txt
+++ b/docs/ref/request-response.txt
@@ -310,6 +310,13 @@ Methods
If you write your own XMLHttpRequest call (on the browser side), you'll
have to set this header manually if you want ``is_ajax()`` to work.
+ If a response varies on whether or not it's requested via AJAX and you are
+ using some form of caching like Django's :mod:`cache middleware
+ <django.middleware.cache>`, you should decorate the view with
+ :func:`vary_on_headers('HTTP_X_REQUESTED_WITH')
+ <django.views.decorators.vary.vary_on_headers>` so that the responses are
+ properly cached.
+
.. method:: HttpRequest.read(size=None)
.. method:: HttpRequest.readline()
.. method:: HttpRequest.readlines()