From e125984394eaca8be82ed6f1ad10075ecd13e806 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 1 Jul 2014 17:32:14 -0400 Subject: [PATCH] [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 --- docs/ref/request-response.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt index 4ad451a325a..cc2e2c088ee 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 + `, you should decorate the view with + :func:`vary_on_headers('HTTP_X_REQUESTED_WITH') + ` so that the responses are + properly cached. + .. method:: HttpRequest.read(size=None) .. method:: HttpRequest.readline() .. method:: HttpRequest.readlines()