Ticket #4946: gzip_enhancements.patch

File gzip_enhancements.patch, 1.4 KB (added by colin@…, 17 years ago)

Patch to enhance gzip middleware.

  • docs/middleware.txt

     
    8989-------------------------------------
    9090
    9191Compresses content for browsers that understand gzip compression (all modern
    92 browsers).
     92browsers).  Useful for webservers that do not support applying gzip to
     93dynamically created content (e.g. Lighttpd without mod_deflate).
    9394
     95Should be placed first in the middleware list so that, being a response
     96middleware, it is execute last.  Will not compress content less than 200 bytes
     97long, responses other than 200, javascript (for IE compatibility) or requests
     98that do not accept gzip encoding.
     99
    94100django.middleware.http.ConditionalGetMiddleware
    95101-----------------------------------------------
    96102
  • django/middleware/gzip.py

     
    1111    on the Accept-Encoding header.
    1212    """
    1313    def process_response(self, request, response):
     14        if (response.status_code != 200 or len (response.content) < 200):
     15            # Don't attempt gzip on small responses and 304's, etc
     16            return response
    1417        patch_vary_headers(response, ('Accept-Encoding',))
    1518       
    1619        # Avoid gzipping if we've already got a content-encoding or if the
Back to Top