title: Should I use a GZIP compression middleware or not?
body: <p>Having worked with <a href="http://www.djangoproject.com/" rel="noreferrer">Django</a>, I've seen that people tend to reccommend the use of <a href="http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.gzip" rel="noreferrer">GZIP Middleware</a> to compress HTML pages.</p>
  
  <p>However, the <a href="http://www.python.org/dev/peps/pep-0333/#handling-the-content-length-header" rel="noreferrer">WSGI v1.0 specification</a> tells us:</p>
  
  <blockquote>
    <p>(Note: applications and middleware <strong>must not</strong> apply any kind of <code>Transfer-Encoding</code> to their output, such as chunking or gzipping; as "hop-by-hop" operations, these encodings are the province of the actual web server/gateway. See <a href="http://www.python.org/dev/peps/pep-0333/#other-http-features" rel="noreferrer">Other HTTP Features</a> below, for more details.)</p>
  </blockquote>
  
  <p>This suggests that compression should be left to the server/gateway. Which makes sense, as the server is probably much faster in doing that. Also, it might prefer <a href="http://en.wikipedia.org/wiki/SDCH" rel="noreferrer">SDCH</a> over gzip, as most modern Chrome/Chromium browsers support it.</p>
  
  <p>So my question remains, should I use a middleware to compress my responses or not? Specifically, what is the right choice for <a href="http://code.google.com/appengine/" rel="noreferrer">Google App Engine</a>?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The Pylons Book also contains an <a href="http://pylonsbook.com/en/1.1/the-web-server-gateway-interface-wsgi.html#writing-wsgi-middleware" rel="noreferrer">example gzip middleware</a>.</p>
  
  <p>I didn't mention that my framework of choice is <a href="http://docs.pylonshq.com/pyramid/dev/" rel="noreferrer">Pyramid</a> (ex-repoze.bfg).</p>