From d08d4f464ab11cc226d4e197c0f43e26a7fd2961 Mon Sep 17 00:00:00 2001 From: Flavio Curella Date: Thu, 26 Sep 2019 11:41:38 -0700 Subject: Fixed #30765 -- Made cache_page decorator take precedence over max-age Cache-Control directive. --- docs/releases/3.1.txt | 4 ++++ docs/topics/cache.txt | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'docs') diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt index 9e8dff3456..064aadd34a 100644 --- a/docs/releases/3.1.txt +++ b/docs/releases/3.1.txt @@ -430,6 +430,10 @@ Miscellaneous used with :setting:`DEFAULT_EXCEPTION_REPORTER_FILTER` needs to inherit from :class:`django.views.debug.SafeExceptionReporterFilter`. +* The cache timeout set by :func:`~django.views.decorators.cache.cache_page` + decorator now takes precedence over the ``max-age`` directive from the + ``Cache-Control`` header. + .. _deprecated-features-3.1: Features deprecated in 3.1 diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index 29ea8fb001..bc6b96ecfe 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -570,6 +570,9 @@ minutes. (Note that we've written it as ``60 * 15`` for the purpose of readability. ``60 * 15`` will be evaluated to ``900`` -- that is, 15 minutes multiplied by 60 seconds per minute.) +The cache timeout set by ``cache_page`` takes precedence over the ``max-age`` +directive from the ``Cache-Control`` header. + The per-view cache, like the per-site cache, is keyed off of the URL. If multiple URLs point at the same view, each URL will be cached separately. Continuing the ``my_view`` example, if your URLconf looks like this:: @@ -605,6 +608,11 @@ The ``key_prefix`` and ``cache`` arguments may be specified together. The ``key_prefix`` argument and the :setting:`KEY_PREFIX ` specified under :setting:`CACHES` will be concatenated. +.. versionchanged:: 3.1 + + In older versions, the ``max-age`` directive from the ``Cache-Control`` + header had precedence over the cache timeout set by ``cache_page``. + Specifying per-view cache in the URLconf ---------------------------------------- -- cgit v1.3