summaryrefslogtreecommitdiff
path: root/django/middleware/cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/middleware/cache.py')
-rw-r--r--django/middleware/cache.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/django/middleware/cache.py b/django/middleware/cache.py
index 83860e15f3..e13a8c3918 100644
--- a/django/middleware/cache.py
+++ b/django/middleware/cache.py
@@ -29,11 +29,6 @@ More details about how the caching works:
of the response's "Cache-Control" header, falling back to the
CACHE_MIDDLEWARE_SECONDS setting if the section was not found.
-* If CACHE_MIDDLEWARE_ANONYMOUS_ONLY is set to True, only anonymous requests
- (i.e., those not made by a logged-in user) will be cached. This is a simple
- and effective way of avoiding the caching of the Django admin (and any other
- user-specific content).
-
* This middleware expects that a HEAD request is answered with the same response
headers exactly like the corresponding GET request.
@@ -48,6 +43,8 @@ More details about how the caching works:
"""
+import warnings
+
from django.conf import settings
from django.core.cache import get_cache, DEFAULT_CACHE_ALIAS
from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age
@@ -200,5 +197,9 @@ class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
else:
self.cache_anonymous_only = cache_anonymous_only
+ if self.cache_anonymous_only:
+ msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8."
+ warnings.warn(msg, PendingDeprecationWarning, stacklevel=1)
+
self.cache = get_cache(self.cache_alias, **cache_kwargs)
self.cache_timeout = self.cache.default_timeout