Index: bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.15
diff -u -F^f -r1.15 bootstrap.inc
--- bootstrap.inc	2 Jul 2004 18:46:40 -0000	1.15
+++ bootstrap.inc	7 Jul 2004 10:18:30 -0000
@@ -86,7 +86,7 @@ function page_set_cache() {
   if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET') {
     // This will fail in some cases, see page_get_cache() for the explanation.
     if ($data = ob_get_contents()) {
-      cache_set(request_uri(), $data, 1, drupal_get_headers());
+      cache_set(request_uri(), function_exists('gzencode') ? (version_compare(phpversion(), '4.2', '>=') ? gzencode($data, FORCE_GZIP) : gzencode($data, 9, FORCE_GZIP)): $data, 1, drupal_get_headers());
     }
   }
 }
@@ -145,6 +145,15 @@ function drupal_page_header() {
       header("Last-Modified: $date");
       header("ETag: $etag");
 
+      // Determine if the browser accepts gzipped data
+      if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false && function_exists('gzencode')) {
+        // strip the gzip header and run uncompress
+        $cache->data = gzinflate(substr(substr($cache->data, 10), 0, -8));
+      }
+      elseif (function_exists('gzencode')) {
+        header('Content-Encoding: gzip');
+      }
+
       /*
       ** Send the original request's headers.  We send them one after
       ** another so PHP's header() function can deal with duplicate
