Opened 16 years ago

Closed 16 years ago

#9221 closed (fixed)

Cache Middleware wrong behavior.

Reported by: Wonlay Owned by: nobody
Component: Core (Cache system) Version: dev
Severity: Keywords: CACHE_MIDDLEWARE_SECONDS, zero
Cc: wonlay@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When the CACHE_MIDDLEWARE_SECONDS setting is set to zero,

UpdateCacheMiddleware will set a cache item which timeout is 300.

# This line pass timeout=0.
cache.set(cache_key, response, timeout)

# But in django/core/cache/backends/memcached.py:
self._cache.set(smart_str(key), value, timeout or self.default_timeout)
# will set the timeout to self.default_timeout, which is 300.

Actually, if CACHE_MIDDLEWARE_SECONDS=0 there is no need to call cache.set(...
Only patch the header max_age to 0 will be OK.

And my patch attached.

Attachments (1)

cache_timeout_0_bug.patch (715 bytes ) - added by Wonlay 16 years ago.

Download all attachments as: .zip

Change History (3)

by Wonlay, 16 years ago

Attachment: cache_timeout_0_bug.patch added

comment:1 by Wonlay, 16 years ago

Cc: wonlay@… added

comment:2 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [9098]) 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.

Note: See TracTickets for help on using tickets.
Back to Top