Opened 16 years ago

Closed 16 years ago

#6452 closed (fixed)

Catch 22 in Cache Documentation

Reported by: pavera Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the cache documentation it states that to cache anonymous requests only (IE you don't want to cache logged in user pages) you use CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True in the settings file. It then states that to use this successfully CacheMiddleware must appear after AuthenticationMiddleware, which makes sense. Under Order of MIDDLEWARE_CLASSES in the same document however, it says CacheMiddleware should appear before SessionMiddleware so that headers are set correctly, which seems to make sense to me as well.

Unfortunately, there is an already existing requirement that AuthenticationMiddleware must come after SessionMiddleware, so the only way to phrase this and get Django to run successfully is:

  1. SessionMiddleware
  2. AuthenticationMiddleware
  3. CacheMiddleware

However, that violates the documentation which states that CacheMiddleware should come before SessionMiddleware.

I do not know if this is an error in the documentation, or if some hacking needs to be applied to the various middlewares so that all of the requirements can be satisfied.

Change History (2)

comment:1 by Simon Greenhill <dev@…>, 16 years ago

Triage Stage: UnreviewedAccepted

comment:2 by James Bennett, 16 years ago

Resolution: fixed
Status: newclosed

[8260] fixed this by splitting up the cache middleware into separate classes which can be placed at the correct points.

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