Opened 23 months ago

Closed 18 months ago

Last modified 18 months ago

#18473 closed Bug (fixed)

Contradictory advice on middleware order

Reported by: david@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords: middleware order GZipMiddleware UpdateCacheMiddleware
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



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.


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 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.

Attachments (0)

Change History (3)

comment:1 Changed 23 months ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Cleanup/optimization to Bug

The gzip docs should say something like it should run after anything else that needs to read/write the response body.

comment:2 Changed 18 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 3e0857041b6bfc9deef392315c978abede706c92:

Fixed #18473 - Fixed a suggestion that GZipMiddleware needs to be first in the list of middleware.

comment:3 Changed 18 months ago by Tim Graham <timograham@…>

In 73991b0b325f07fc62179c3684ed921f141e69ce:

[1.4.X] Fixed #18473 - Fixed a suggestion that GZipMiddleware needs to be first in the list of middleware.

Backport of 3e0857041b from master

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.