Django

Code

Ticket #9221 (closed: fixed)

Opened 2 months ago

Last modified 2 months ago

Cache Middleware wrong behavior.

Reported by: Wonlay Assigned to: nobody
Milestone: Component: Cache system
Version: SVN Keywords: CACHE_MIDDLEWARE_SECONDS, zero
Cc: wonlay@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

cache_timeout_0_bug.patch (0.7 kB) - added by Wonlay on 09/27/08 01:46:36.

Change History

09/27/08 01:46:36 changed by Wonlay

  • attachment cache_timeout_0_bug.patch added.

09/27/08 06:55:49 changed by Wonlay

  • cc set to wonlay@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

09/29/08 22:58:10 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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.


Add/Change #9221 (Cache Middleware wrong behavior.)




Change Properties
Action