hi list, I got some Problems with the middlewareorder of cachemiddlerware, since it does not seem possible to order it the right way.
>Put the CacheMiddleware before any other middleware that might add >something to the Vary header (response middleware is applied in reverse >order). The following middleware modules do so: > > * SessionMiddleware adds Cookie > * GZipMiddleware adds Accept-Encoding > * LocaleMiddleware adds Accept-Language this is part of the documentation and seems easy to follow, but: >The cache middleware caches every page that doesn’t have GET or POST >parameters. Optionally, if the CACHE_MIDDLEWARE_ANONYMOUS_ONLY setting >is True, only anonymous requests (i.e., not those made by a logged-in >user) will be cached. This is a simple and effective way of disabling >caching for any user-specific pages (include Django’s admin interface). >Note that if you use CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you should make >sure you’ve activated AuthenticationMiddleware and that >AuthenticationMiddleware appears before CacheMiddleware in your >MIDDLEWARE_CLASSES. now problem is, that authentication middleware must have sessionmiddleware before itself. else django fails to start: >AssertionError: The Django authentication middleware requires session >middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to >insert 'django.contrib.sessions.middleware.SessionMiddleware'. If I try to get authenticationmiddleware after cachemiddleware I get another error: >AssertionError: The Django cache middleware with >CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication >middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to >insert 'django.contrib.auth.middleware.AuthenticationMiddleware' >before the CacheMiddleware. the only way to get a working djangoinstance is to put sessionmiddleware _before_ cachemiddleware, what you shouldn't do according to the docs. is this a mistake in the docs or an error in django? greetz Paul Rauch
signature.asc
Description: PGP signature