On Wed, 2007-12-05 at 15:26 +0100, Paul Rauch wrote: > 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 doesnt 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 Djangos admin interface). > >Note that if you use CACHE_MIDDLEWARE_ANONYMOUS_ONLY, you should make > >sure youve 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?
If you're using CACHE_MIDDLEWARE_ANONYMOUS_ONLY you need a different middleware ordering, as the error message says. That setting is a real hack and I'd love to implement it in a better way some day. At the moment, though, where you place the cache middleware depends on whether you're using that setting or not. Malcolm -- Honk if you love peace and quiet. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---