From 4288c8831bde86f1be581d65c13e2f878a02c7ff Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 9 Jan 2012 21:42:03 +0000 Subject: Fixed #10762, #17514 -- Prevented the GZip middleware from returning a response longer than the original content, allowed compression of non-200 responses, and added tests (there were none). Thanks cannona for the initial patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17365 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/middleware.txt | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt index 737e0b2598..d57dbc9adc 100644 --- a/docs/ref/middleware.txt +++ b/docs/ref/middleware.txt @@ -82,22 +82,29 @@ addresses defined in the :setting:`INTERNAL_IPS` setting. This is used by Django's :doc:`automatic documentation system `. Depends on :class:`~django.contrib.auth.middleware.AuthenticationMiddleware`. -GZIP middleware +GZip middleware --------------- .. module:: django.middleware.gzip - :synopsis: Middleware to serve gziped content for performance. + :synopsis: Middleware to serve GZipped content for performance. .. class:: GZipMiddleware -Compresses content for browsers that understand gzip compression (all modern +Compresses content for browsers that understand GZip compression (all modern browsers). It is suggested to place this first in the middleware list, so that the -compression of the response content is the last thing that happens. Will not -compress content bodies less than 200 bytes long, when the response code is -something other than 200, JavaScript files (for IE compatibility), or -responses that have the ``Content-Encoding`` header already specified. +compression of the response content is the last thing that happens. + +It will not compress content bodies less than 200 bytes long, when the +``Content-Encoding`` header is already set, or when the browser does not send +an ``Accept-Encoding`` header containing ``gzip``. + +Content will also not be compressed when the browser is Internet Explorer and +the ``Content-Type`` header contains ``javascript`` or starts with anything +other than ``text/``. This is done to overcome a bug present in early versions +of Internet Explorer which caused decompression not to be performed on certain +content types. GZip compression can be applied to individual views using the :func:`~django.views.decorators.http.gzip_page()` decorator. -- cgit v1.3