Ticket #8034: gzip_middleware_no_images.2.diff

File gzip_middleware_no_images.2.diff, 796 bytes (added by magneto, 16 years ago)

Video and Images omit in Gzip (and use starts with)

  • middleware/gzip.py

    (this hunk was shorter than expected)  
    44from django.utils.cache import patch_vary_headers
    55
    66re_accepts_gzip = re.compile(r'\bgzip\b')
    77
    88class GZipMiddleware(object):
    99    """
     
    1213    on the Accept-Encoding header.
    1314    """
    1415    def process_response(self, request, response):
     16        ctype = response.get('Content-Type', '').lower()
     17        if ctype and (ctype.startswith('image') or ctype.startswith('video')):
     18            return response
     19           
    1520        # It's not worth compressing non-OK or really short responses.
    1621        if response.status_code != 200 or len(response.content) < 200:
    1722            return response
Back to Top