You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split CacheMiddleware up into two parts -- an update-cache and a fetch-from-cache middleware. This lets you run each half of the cache middleware at the correct time to avoid bad interactions between the cache middleware and other middleware that must modify the cache key (like the locale middleware).
CacheMiddleware itself is still around for backwards-compatibility and as a hook point for the cache decorator, but the documentation has been updated to point people towards the two-part caching middleware.
Refs #730.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8260 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* This middleware expects that a HEAD request is answered with a response
37
+
exactly like the corresponding GET request.
45
38
46
-
defprocess_request(self, request):
47
-
"Checks whether the page is already cached and returns the cached version if available."
48
-
ifself.cache_anonymous_only:
49
-
asserthasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware."
39
+
* When a hit occurs, a shallow copy of the original response object is returned
Checks whether the page is already cached and returns the cached
111
+
version if available.
112
+
"""
113
+
ifself.cache_anonymous_only:
114
+
asserthasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware."
Copy file name to clipboardExpand all lines: docs/cache.txt
+29-14Lines changed: 29 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -231,17 +231,25 @@ arguments.
231
231
The per-site cache
232
232
==================
233
233
234
+
**New in Django development version** (previous versions of Django only provided a single ``CacheMiddleware`` instead of the two pieces described below).
235
+
234
236
Once the cache is set up, the simplest way to use caching is to cache your
235
-
entire site. Just add ``'django.middleware.cache.CacheMiddleware'`` to your
237
+
entire site. You'll need to add
238
+
``'django.middleware.cache.UpdateCacheMiddleware'`` and
239
+
``'django.middleware.cache.FetchFromCacheMiddleware' to your
236
240
``MIDDLEWARE_CLASSES`` setting, as in this example::
0 commit comments