Ticket #4946: gzip_enhancements.patch
File gzip_enhancements.patch, 1.4 KB (added by , 17 years ago) |
---|
-
docs/middleware.txt
89 89 ------------------------------------- 90 90 91 91 Compresses content for browsers that understand gzip compression (all modern 92 browsers). 92 browsers). Useful for webservers that do not support applying gzip to 93 dynamically created content (e.g. Lighttpd without mod_deflate). 93 94 95 Should be placed first in the middleware list so that, being a response 96 middleware, it is execute last. Will not compress content less than 200 bytes 97 long, responses other than 200, javascript (for IE compatibility) or requests 98 that do not accept gzip encoding. 99 94 100 django.middleware.http.ConditionalGetMiddleware 95 101 ----------------------------------------------- 96 102 -
django/middleware/gzip.py
11 11 on the Accept-Encoding header. 12 12 """ 13 13 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 14 17 patch_vary_headers(response, ('Accept-Encoding',)) 15 18 16 19 # Avoid gzipping if we've already got a content-encoding or if the