Django

Code

Changeset 5875

Show
Ignore:
Timestamp:
08/12/07 07:29:25 (1 year ago)
Author:
mtredinnick
Message:

Fixed #4946 -- Added some small improvements to Gzip middleware. Thanks, colin@owlfish.com.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/middleware/gzip.py

    r4265 r5875  
    1212    """ 
    1313    def process_response(self, request, response): 
     14        if response.status_code != 200 or len(response.content) < 200: 
     15            # Not worth compressing really short responses or 304 status 
     16            # responses, etc. 
     17            return response 
     18 
    1419        patch_vary_headers(response, ('Accept-Encoding',)) 
    1520         
  • django/trunk/docs/middleware.txt

    r5670 r5875  
    9292browsers). 
    9393 
     94It is suggested to place this first in the middleware list, so that the 
     95compression of the response content is the last thing that happens. Will not 
     96compress content bodies less than 200 bytes long, when the response code is 
     97something other than 200, Javascript files (for IE compatibitility), or 
     98responses that have the ``Content-Encoding`` header already specified. 
     99 
    94100django.middleware.http.ConditionalGetMiddleware 
    95101-----------------------------------------------