summaryrefslogtreecommitdiff
path: root/docs/cache.txt
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2005-10-29 17:00:20 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2005-10-29 17:00:20 +0000
commitf12e3243326a2b6b0d09206b373b34e028eab25c (patch)
tree706dab0c8455592749216f2ca724bdc1ec178c98 /docs/cache.txt
parent67d490a61dc5ee42b972f6c64bf589fbfc8db83f (diff)
Fixed #612 - added cache control headers (thanks, hugo)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1020 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/cache.txt')
-rw-r--r--docs/cache.txt34
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/cache.txt b/docs/cache.txt
index f15da2660b..7db42db249 100644
--- a/docs/cache.txt
+++ b/docs/cache.txt
@@ -270,6 +270,40 @@ and a list/tuple of header names as its second argument.
.. _`HTTP Vary headers`: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44
+Controlling cache: Using Vary headers
+=====================================
+
+Another problem with caching is the privacy of data, and the question where data can
+be stored in a cascade of caches. A user usually faces two kinds of caches: his own
+browser cache (a private cache) and his providers cache (a public cache). A public cache
+is used by multiple users and controlled by someone else. This poses problems with private
+(in the sense of sensitive) data - you don't want your social security number or your
+banking account numbers stored in some public cache. So web applications need a way
+to tell the caches what data is private and what is public.
+
+Other aspects are the definition how long a page should be cached at max, or wether the
+cache should allways check for newer versions and only deliver the cache content when
+there were no changes (some caches might deliver cached content even if the server page
+changed - just because the cache copy isn't yet expired).
+
+So there are a multitude of options you can control for your pages. This is where the
+Cache-Control header (more infos in `HTTP Cache-Control headers`_) comes in. The usage
+is quite simple::
+
+ @cache_control(private=True, must_revalidate=True, max_age=3600)
+ def my_view(request):
+ ...
+
+This would define the view as private, to be revalidated on every access and cache
+copies will only be stored for 3600 seconds at max.
+
+The caching middleware already set's this header up with a max-age of the CACHE_MIDDLEWARE_SETTINGS
+setting. And the cache_page decorator does the same. The cache_control decorator correctly merges
+different values into one big header, though. But you should take into account that middlewares
+might overwrite some of your headers or set their own defaults if you don't give that header yourself.
+
+.. _`HTTP Cache-Control headers`: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
+
Other optimizations
===================