Loading django/utils/cache.py +1 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ def add_never_cache_headers(response): Adds headers to a response to indicate that a page should never be cached. """ patch_response_headers(response, cache_timeout=-1) patch_cache_control(response, no_cache=True, no_store=True, must_revalidate=True) def patch_vary_headers(response, newheaders): Loading docs/ref/contrib/admin/index.txt +1 −1 Original line number Diff line number Diff line Loading @@ -1474,7 +1474,7 @@ templates used by the :class:`ModelAdmin` views: url(r'^my_view/$', self.admin_site.admin_view(self.my_view)) This wrapping will protect ``self.my_view`` from unauthorized access and will apply the ``django.views.decorators.cache.never_cache`` decorator to will apply the :func:`django.views.decorators.cache.never_cache` decorator to make sure it is not cached if the cache middleware is active. If the page is cacheable, but you still want the permission check to be Loading docs/ref/utils.txt +7 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,13 @@ need to distinguish caches by the ``Accept-language`` header. .. function:: add_never_cache_headers(response) Adds headers to a response to indicate that a page should never be cached. Adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate`` header to a response to indicate that a page should never be cached. .. versionchanged:: 1.9 Before Django 1.9, ``Cache-Control: max-age=0`` was sent. This didn't reliably prevent caching in all browsers. .. function:: patch_vary_headers(response, newheaders) Loading docs/releases/1.9.txt +4 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,10 @@ Cache * ``django.core.cache.backends.base.BaseCache`` now has a ``get_or_set()`` method. * :func:`django.views.decorators.cache.never_cache` now sends more persuasive headers (added ``no-cache, no-store, must-revalidate`` to ``Cache-Control``) to better prevent caching. Email ^^^^^ Loading docs/topics/cache.txt +1 −1 Original line number Diff line number Diff line Loading @@ -1209,7 +1209,7 @@ the value of the :setting:`CACHE_MIDDLEWARE_SECONDS` setting. If you use a custo precedence, and the header values will be merged correctly.) If you want to use headers to disable caching altogether, ``django.views.decorators.cache.never_cache`` is a view decorator that adds :func:`django.views.decorators.cache.never_cache` is a view decorator that adds headers to ensure the response won't be cached by browsers or other caches. Example:: Loading Loading
django/utils/cache.py +1 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ def add_never_cache_headers(response): Adds headers to a response to indicate that a page should never be cached. """ patch_response_headers(response, cache_timeout=-1) patch_cache_control(response, no_cache=True, no_store=True, must_revalidate=True) def patch_vary_headers(response, newheaders): Loading
docs/ref/contrib/admin/index.txt +1 −1 Original line number Diff line number Diff line Loading @@ -1474,7 +1474,7 @@ templates used by the :class:`ModelAdmin` views: url(r'^my_view/$', self.admin_site.admin_view(self.my_view)) This wrapping will protect ``self.my_view`` from unauthorized access and will apply the ``django.views.decorators.cache.never_cache`` decorator to will apply the :func:`django.views.decorators.cache.never_cache` decorator to make sure it is not cached if the cache middleware is active. If the page is cacheable, but you still want the permission check to be Loading
docs/ref/utils.txt +7 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,13 @@ need to distinguish caches by the ``Accept-language`` header. .. function:: add_never_cache_headers(response) Adds headers to a response to indicate that a page should never be cached. Adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate`` header to a response to indicate that a page should never be cached. .. versionchanged:: 1.9 Before Django 1.9, ``Cache-Control: max-age=0`` was sent. This didn't reliably prevent caching in all browsers. .. function:: patch_vary_headers(response, newheaders) Loading
docs/releases/1.9.txt +4 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,10 @@ Cache * ``django.core.cache.backends.base.BaseCache`` now has a ``get_or_set()`` method. * :func:`django.views.decorators.cache.never_cache` now sends more persuasive headers (added ``no-cache, no-store, must-revalidate`` to ``Cache-Control``) to better prevent caching. Email ^^^^^ Loading
docs/topics/cache.txt +1 −1 Original line number Diff line number Diff line Loading @@ -1209,7 +1209,7 @@ the value of the :setting:`CACHE_MIDDLEWARE_SECONDS` setting. If you use a custo precedence, and the header values will be merged correctly.) If you want to use headers to disable caching altogether, ``django.views.decorators.cache.never_cache`` is a view decorator that adds :func:`django.views.decorators.cache.never_cache` is a view decorator that adds headers to ensure the response won't be cached by browsers or other caches. Example:: Loading