Ticket #20987: cache.py.patch
File cache.py.patch, 1.8 KB (added by , 11 years ago) |
---|
-
middleware/
old new 66 66 self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS 67 67 self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX 68 68 self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) 69 self.cache_middleware_disable_for_authenticated = getattr(settings, 'CACHE_MIDDLEWARE_DISABLE_FOR_AUTHENTICATED', False)70 69 self.cache_alias = settings.CACHE_MIDDLEWARE_ALIAS 71 70 self.cache = get_cache(self.cache_alias) 72 71 … … 87 86 if request.user.is_authenticated(): 88 87 # Don't cache user-variable requests from authenticated users. 89 88 return False 90 if self.cache_middleware_disable_for_authenticated:91 return False92 89 return True 93 90 94 91 def process_response(self, request, response): … … 130 127 self.cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS 131 128 self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX 132 129 self.cache_anonymous_only = getattr(settings, 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY', False) 133 self.cache_middleware_disable_for_authenticated = getattr(settings, 'CACHE_MIDDLEWARE_DISABLE_FOR_AUTHENTICATED', False)134 130 self.cache_alias = settings.CACHE_MIDDLEWARE_ALIAS 135 131 self.cache = get_cache(self.cache_alias) 136 132 … … 139 135 Checks whether the page is already cached and returns the cached 140 136 version if available. 141 137 """ 142 if self.cache_middleware_disable_for_authenticated:143 return None144 145 138 if not request.method in ('GET', 'HEAD'): 146 139 request._cache_update_cache = False 147 140 return None # Don't bother checking the cache.