Opened 8 years ago

Last modified 5 weeks ago

#25782 new Cleanup/optimization

Discourage usage of cache_page decorator with UpdateCacheMiddleware (or make middleware ignore decorated views)

Reported by: Serhiy Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Ülgen Sarıkavak Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If django.middleware.cache.UpdateCacheMiddleware is active and some view is decorated with the cache_page that overrides cache alias, this view will be cached in both caches, first time by cache_page and then by the middleware. Well, at least it will try. And fail if the default cache is memcached and the view response is bigger than its' maximum entry size. While filebased cache will work and even create the cache entry. This way first user to visit when there are no entry in cache will get error instead of data.
So, I guess there should be some warning about this in the docs.
Ideally, middleware should ignore views with overridden cache alias, maybe by means of checking headers like in case of the cache_control decorator.

Change History (3)

comment:1 by Carl Meyer, 8 years ago

Any attempt to fix this should also take into account #15855 -- the cache_page decorator is already basically broken in terms of Vary headers. It shouldn't cache at all, it should mark the response for later caching by the middleware, or something.

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:3 by Ülgen Sarıkavak, 5 weeks ago

Cc: Ülgen Sarıkavak added
Note: See TracTickets for help on using tickets.
Back to Top