Order of MIDDLEWARE_CLASSES

If you use CacheMiddleware, it’s important to put it in the right place within the MIDDLEWARE_CLASSES setting, because the cache middleware needs to know the headers by which to vary the cache storage. Put the CacheMiddleware after any middlewares that might add something to the Vary header, including the following:

  • UpdateCacheMiddleware
  • GZipMiddleware
  • ConditionalGetMiddleware
  • SessionMiddleware
  • LocaleMiddleware
  • CommonMiddleware
  • CsrfViewMiddleware
  • AuthenticationMiddleware
  • MessageMiddleware
  • FetchFromCacheMiddleware
  • FlatpageFallbackMiddleware
  • RedirectFallbackMiddleware

Back to Tutorial

Share this post
[social_warfare]
Other Optimizations
Using the JMXProxyServlet

Get industry recognized certification – Contact us

keyboard_arrow_up