From cc5bbd447bec57165d5bdf062128fdee0df81ee4 Mon Sep 17 00:00:00 2001 From: mgaligniana Date: Fri, 10 Dec 2021 08:26:32 -0300 Subject: [PATCH] [4.0.x] Fixed #33338 -- Doc'd that never_cache() decorator set Expires header. Backport of 669dcefc04837c35fc2ec5ce906d84397005965d from main --- AUTHORS | 1 + docs/ref/utils.txt | 4 ++++ docs/topics/http/decorators.txt | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/AUTHORS b/AUTHORS index 00e51d6bc8..4462b40354 100644 --- a/AUTHORS +++ b/AUTHORS @@ -588,6 +588,7 @@ answer newbie questions, and generally made Django that much better: Marc Aymerich Gubern Marc Egli Marcel Telka + Marcelo Galigniana Marc Fargas Marc Garcia Marcin Wróbel diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index d316c8a8bf..25e5fdb2c9 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -62,10 +62,14 @@ need to distinguish caches by the ``Accept-language`` header. .. function:: add_never_cache_headers(response) + Adds an ``Expires`` header to the current date/time. + Adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate, private`` header to a response to indicate that a page should never be cached. + Each header is only added if it isn't already set. + .. function:: patch_vary_headers(response, newheaders) Adds (or updates) the ``Vary`` header in the given ``HttpResponse`` object. diff --git a/docs/topics/http/decorators.txt b/docs/topics/http/decorators.txt index cabdd4f01a..21ff963071 100644 --- a/docs/topics/http/decorators.txt +++ b/docs/topics/http/decorators.txt @@ -118,10 +118,14 @@ client-side caching. .. function:: never_cache(view_func) + This decorator adds an ``Expires`` header to the current date/time. + This decorator adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate, private`` header to a response to indicate that a page should never be cached. + Each header is only added if it isn't already set. + .. module:: django.views.decorators.common Common