Changeset 3395
- Timestamp:
- 07/20/06 10:37:12 (2 years ago)
- Files:
-
- django/trunk/django/middleware/cache.py (modified) (4 diffs)
- django/trunk/docs/cache.txt (modified) (1 diff)
- django/trunk/docs/faq.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/middleware/cache.py
r3171 r3395 10 10 11 11 Only parameter-less GET or HEAD-requests with status code 200 are cached. 12 13 If CACHE_MIDDLEWARE_ANONYMOUS_ONLY is set to True, only anonymous requests 14 (i.e. those node made by a logged in user) will be cached. This is a 15 simple and effective way of avoiding the caching of the Django admin (and 16 any other user-specific content). 12 17 13 18 This middleware expects that a HEAD request is answered with a response … … 24 29 headers on the response object. 25 30 """ 26 def __init__(self, cache_timeout=None, key_prefix=None ):31 def __init__(self, cache_timeout=None, key_prefix=None, cache_anonymous_only=None): 27 32 self.cache_timeout = cache_timeout 28 33 if cache_timeout is None: … … 31 36 if key_prefix is None: 32 37 self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX 38 if cache_anonymous is None: 39 self.cache_anonymous_only = settings.get('CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) 40 else: 41 self.cache_anonymous_only = cache_anonymous_only 33 42 34 43 def process_request(self, request): … … 37 46 request._cache_update_cache = False 38 47 return None # Don't bother checking the cache. 48 49 if self.cache_anonymous_only and request.user.is_authenticated(): 50 request._cache_update_cache = False 51 return None # Don't cache requests from authenticated users. 39 52 40 53 cache_key = get_cache_key(request, self.key_prefix) django/trunk/docs/cache.txt
r2980 r3395 231 231 232 232 The cache middleware caches every page that doesn't have GET or POST 233 parameters. Additionally, ``CacheMiddleware`` automatically sets a few headers 233 parameters. Optionally, If the ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting is 234 ``True``, only anonymous requests (i.e. those node made by a logged in user) 235 will be cached. This is a simple and effective way of disabling caching on any 236 user-specific content ( include Django's admin interface). 237 238 Additionally, ``CacheMiddleware`` automatically sets a few headers 234 239 in each ``HttpResponse``: 235 240 django/trunk/docs/faq.txt
r3236 r3395 536 536 allows access to users with those two fields both set to True. 537 537 538 How can I prevent the cache middleware from caching the admin site? 539 ------------------------------------------------------------------- 540 541 Set the ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting to ``True``. See the 542 `cache documentation`_ for more information. 543 544 .. _cache documentation: ../cache/#the-per-site-cache 545 538 546 How do I automatically set a field's value to the user who last edited the object in the admin? 539 547 -----------------------------------------------------------------------------------------------
