#18473: Contradictory advice on middleware order -------------------------------------+------------------------------------- Reporter: david@… | Owner: nobody Type: | Status: new Cleanup/optimization | Version: 1.4 Component: Documentation | Keywords: middleware order Severity: Normal | GZipMiddleware Triage Stage: Unreviewed | UpdateCacheMiddleware Easy pickings: 0 | Has patch: 0 | UI/UX: 0 -------------------------------------+------------------------------------- From https://docs.djangoproject.com/en/dev/ref/middleware/#django.middleware.gzip.GZipMiddleware It is suggested to place this first in the middleware list, so that the compression of the response content is the last thing that happens.
From https://docs.djangoproject.com/en/dev/topics/cache/#order-of- middleware-classes you need to make sure that !UpdateCacheMiddleware appears before any other middleware that might add something to the Vary header. The following middleware modules do so: !SessionMiddleware adds Cookie \\ GZipMiddleware adds Accept-Encoding I suspect https://docs.djangoproject.com/en/dev/ref/middleware/#django.middleware.gzip.GZipMiddleware might need to be changed. With GZipMiddleware first, not only will it alter the "Vary" header handling, but presumably it will be recompressing the uncompressed cached content on each request, and it would be better to cache the compressed content instead. -- Ticket URL: <https://code.djangoproject.com/ticket/18473> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.