1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

magic-removal: Slightly cleaned up docs/cache.txt

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2607 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-04-04 00:13:51 +00:00
parent c5beee9500
commit 1764a4dac1

View File

@ -332,17 +332,28 @@ the value of the ``CACHE_MIDDLEWARE_SETTINGS`` setting. If you use a custom
``max_age`` in a ``cache_control`` decorator, the decorator will take
precedence, and the header values will be merged correctly.)
If you want to use headers to disable caching altogether, two utility functions
are provided. `django.utils.cache.add_never_cache_headers`` is a
function that takes a single HttpResponse object as its argument and adds
headers to ensure the response won't be cached by browsers or other caches.
``django.views.decorators.never_cache`` is a view decorator that does the same
thing but can be applied to a view function for convenience. Example::
Disabling HTTP caching for a particular view
============================================
If you want to use headers to disable HTTP caching altogether for a particular
view, use one of the two utility functions the come with Django:
* ``django.utils.cache.add_never_cache_headers`` takes a single
``HttpResponse`` object as its argument and alters the response to adds
headers that ensure the response won't be cached by browsers or other
caches.
* ``django.views.decorators.never_cache`` is a view decorator that does the
same thing but can be applied to a view function for convenience.
Example::
from django.views.decorators.cache import never_cache
@never_cache
def myview(request):
...
# ...
Note that these functions disable HTTP caching (as described in the 'Controlling
Cache' sections of this document) -- they do *not* disable performance caching
(as described in the first few sections of this document).
.. _`Cache-Control spec`: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9