How to enable gzip compression on Heroku Cedar (Python/Flask/Gunicorn) How to enable gzip compression on Heroku Cedar (Python/Flask/Gunicorn) heroku heroku

How to enable gzip compression on Heroku Cedar (Python/Flask/Gunicorn)


According to the WSGI spec, published 2003, apps shouldn't gzip responses but leave that to the server (presumed to be Apache, running the app CGI-stylee).

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.

But today in 2013, often the app is the server. WSGI didn't anticipate this. That's a problem, according to http://www.b-list.org/weblog/2009/aug/10/wsgi/

WSGI’s curious insistence on compatibility with CGI also means that, here in 2009, the Python web-development world still hasn’t been able to significantly improve on 1997’s application programming model.