Opened 3 years ago

Closed 2 years ago

#19153 closed Cleanup/optimization (wontfix)

Deprecate GzipMiddleware

Reported by: aaugustin Owned by: nobody
Component: HTTP handling Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Per PEP 3333:

applications and middleware must not apply any kind of Transfer-Encoding to their output, such as chunking or gzipping; as "hop-by-hop" operations, these encodings are the province of the actual web server/gateway.

Since WSGI has become by far the most common way to deploy Django — I don't even know any other way — Django should stop providing GzipMiddleware.

This idea was approved by a BDFL on IRC:

20-00:10:33     jacobkm Oh and +1 on deprecating gzip middleware

Change History (7)

comment:2 Changed 3 years ago by Elvard

  • Triage Stage changed from Accepted to Ready for checkin

Doesn't merge cleanly against master, since docs/releases/1.5.txt is probably intensively updated before release.
Patch works anyway.

comment:3 Changed 3 years ago by aaugustin

  • Triage Stage changed from Ready for checkin to Accepted

If it doesn't merge then it isn't ready for checkin :)

I created a ticket instead of doing it myself because I think this deserves a serious discussion. Even though gzipping at the application level in wrong in theory, tons of people are doing it and it works in practice.

I'd like to see a discussion on django-developers before proceeding with this deprecation.

comment:4 Changed 3 years ago by Elvard

Oh, I'm sorry, the problem with merge was only in docs/releases/1.5.txt and it was trivial one.

comment:5 Changed 2 years ago by aaugustin

Since filing this bug, I've come across a use case for GzipMiddleware.

It requires running Django with USE_ETAGS = True behind nginx, with gzip compression enabled. In this situation, nginx will remove the etag (in modern versions) or keep it unchanged (in older versions). To get the correct behavior — ie. gzipping if the client supports it, and a different etag for the gzipped and non-gzipped version — you have to do the compression in Django.

Related: #19705 and #16035.

comment:6 Changed 2 years ago by timo

Should we mark this as "won't fix" then?

comment:7 Changed 2 years ago by timo

  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top