Django

Code

Ticket #1509 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

[patch] add anonymous-only caching to CacheMiddleware

Reported by: matt Assigned to: jacob
Milestone: Component: Cache system
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Here is a patch against trunk's django.middleware.cache.CacheMiddleware? to optionally only cache anonymously requested (non-logged-in user) pages. Since rendered pages may contain user-specific information if they are logged in, caching those site-wide is often a bad idea. With this mdified middleware and CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True in your settings file, django can cache your non-logged in pages while serving up non-cached pages to logged in users.

I'm not a huge fan of CACHE_MIDDLEWARE_ANONYMOUS_ONLY so if someone thinks of a better name for it, feel free.

Attachments

anonymous_caching.patch (2.2 kB) - added by matt on 03/17/06 11:34:37.
patch for caching anonymous-only

Change History

03/17/06 11:34:37 changed by matt

  • attachment anonymous_caching.patch added.

patch for caching anonymous-only

06/17/06 22:33:06 changed by mtredinnick

I'm not a fan of this way of implementing this. I would prefer a view decorator function to indicate this sort of thing. It feels like more of a per-view thing than a per-project thing to me.

07/20/06 10:37:13 changed by jacob

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

(In [3395]) Added a CACHE_MIDDLEWARE_ANONYMOUS_ONLY setting which makes the cache ignore pages served to authenticated users. Fixes #1509 (thanks, Matt).

Also added a FAQ entry about using this setting to avoid caching of the admin interface.


Add/Change #1509 ([patch] add anonymous-only caching to CacheMiddleware)




Change Properties
Action