Catch 22 in Cache Documentation
|Reported by:||pavera||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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:
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.