Login

Snippets by nf

Snippet List

Strip Google Analytics cookies for caching middleware purposes

You may notice that using Google Analytics's 'urchin' with the CacheMiddleware and SessionMiddleware or AuthenticationMiddleware middleware classes means that nothing is ever cached. Google Analytics updates its cookies with every page view, and the Auth/Session middlewares add cookies to the caching engine's 'Vary' list. This means every page view is given a unique cache key. This middleware class will remove urchin's '__utmX' cookies from the request object before it hits the caching middleware. Put it at the top of your MIDDLEWARE_CLASSES in settings.py. nf / [email protected]

  • middleware
  • cache
  • google
  • analytics
Read More
Author: nf
  • 7
  • 13

nf has posted 1 snippet.