Index: docs/middleware.txt
===================================================================
--- docs/middleware.txt	(revision 5741)
+++ docs/middleware.txt	(working copy)
@@ -89,8 +89,14 @@
 -------------------------------------
 
 Compresses content for browsers that understand gzip compression (all modern
-browsers).
+browsers).  Useful for webservers that do not support applying gzip to 
+dynamically created content (e.g. Lighttpd without mod_deflate).
 
+Should be placed first in the middleware list so that, being a response
+middleware, it is execute last.  Will not compress content less than 200 bytes
+long, responses other than 200, javascript (for IE compatibility) or requests
+that do not accept gzip encoding.
+
 django.middleware.http.ConditionalGetMiddleware
 -----------------------------------------------
 
Index: django/middleware/gzip.py
===================================================================
--- django/middleware/gzip.py	(revision 5741)
+++ django/middleware/gzip.py	(working copy)
@@ -11,6 +11,9 @@
     on the Accept-Encoding header.
     """
     def process_response(self, request, response):
+        if (response.status_code != 200 or len (response.content) < 200):
+            # Don't attempt gzip on small responses and 304's, etc
+            return response
         patch_vary_headers(response, ('Accept-Encoding',))
         
         # Avoid gzipping if we've already got a content-encoding or if the
