summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-09-30 03:58:09 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-09-30 03:58:09 +0000
commitba592950689a06893c77bc97040770f89dd5a317 (patch)
treee4580a65502a70f51c350501757c5043b5d8b3a0
parente9f647e11f9ee77dea71f9302904474c13ff3b5a (diff)
Fixed #9221 -- Small optimisation to caching middleware handling.
In the slightly unusual case that CACHE_MIDDLEWARE_SECONDS is set to 0, don't bother storing a copy in the local cache. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/middleware/cache.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/middleware/cache.py b/django/middleware/cache.py
index 28e878400a..3f602fe652 100644
--- a/django/middleware/cache.py
+++ b/django/middleware/cache.py
@@ -89,8 +89,9 @@ class UpdateCacheMiddleware(object):
# max-age was set to 0, don't bother caching.
return response
patch_response_headers(response, timeout)
- cache_key = learn_cache_key(request, response, timeout, self.key_prefix)
- cache.set(cache_key, response, timeout)
+ if timeout:
+ cache_key = learn_cache_key(request, response, timeout, self.key_prefix)
+ cache.set(cache_key, response, timeout)
return response
class FetchFromCacheMiddleware(object):