Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.243
diff -u -9 -p -r1.243 bootstrap.inc
--- includes/bootstrap.inc	31 Oct 2008 02:18:22 -0000	1.243
+++ includes/bootstrap.inc	1 Nov 2008 17:12:46 -0000
@@ -723,24 +723,26 @@ function drupal_page_cache_header($cache
   // Send appropriate response:
   header("Last-Modified: $last_modified");
   header("ETag: $etag");
 
   // The following headers force validation of cache:
   header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
   header("Cache-Control: must-revalidate");
 
   if (variable_get('page_compression', TRUE)) {
+    // $cache->data is already gzip'ed, so disable zlib.output_compression.
+    ini_set('zlib.output_compression', 0);
     // Determine if the browser accepts gzipped data.
-    if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE && function_exists('gzencode')) {
+    if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE) {
       // Strip the gzip header and run uncompress.
       $cache->data = gzinflate(substr(substr($cache->data, 10), 0, -8));
     }
-    elseif (function_exists('gzencode')) {
+    else {
       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
   // headers.
   $headers = explode("\n", $cache->headers);
   foreach ($headers as $header) {
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.814
diff -u -9 -p -r1.814 common.inc
--- includes/common.inc	31 Oct 2008 02:23:24 -0000	1.814
+++ includes/common.inc	1 Nov 2008 17:12:47 -0000
@@ -2690,29 +2690,20 @@ function _drupal_bootstrap_full() {
  * @see drupal_page_header
  */
 function page_set_cache() {
   global $user, $base_root;
 
   if (!$user->uid && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && count(drupal_get_messages(NULL, FALSE)) == 0) {
     // This will fail in some cases, see page_get_cache() for the explanation.
     if ($data = ob_get_contents()) {
       $cache = TRUE;
-      if (variable_get('page_compression', TRUE) && function_exists('gzencode')) {
-        // We do not store the data in case the zlib mode is deflate.
-        // This should be rarely happening.
-        if (zlib_get_coding_type() == 'deflate') {
-          $cache = FALSE;
-        }
-        elseif (zlib_get_coding_type() == FALSE) {
-          $data = gzencode($data, 9, FORCE_GZIP);
-        }
-        // The remaining case is 'gzip' which means the data is
-        // already compressed and nothing left to do but to store it.
+      if (variable_get('page_compression', TRUE)) {
+        $data = gzencode($data, 9, FORCE_GZIP);
       }
       ob_end_flush();
       if ($cache && $data) {
         cache_set($base_root . request_uri(), $data, 'cache_page', CACHE_TEMPORARY, drupal_get_headers());
       }
     }
   }
 }
 
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.102
diff -u -9 -p -r1.102 system.admin.inc
--- modules/system/system.admin.inc	16 Oct 2008 20:23:08 -0000	1.102
+++ modules/system/system.admin.inc	1 Nov 2008 17:12:47 -0000
@@ -1354,20 +1354,21 @@ function system_performance_settings() {
     '#title' => t('Minimum cache lifetime'),
     '#default_value' => variable_get('cache_lifetime', 0),
     '#options' => $period,
     '#description' => t('On high-traffic sites, it may be necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied and recreated, and is applied to both page and block caches. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
   );
   $form['page_cache']['page_compression'] = array(
     '#type' => 'radios',
     '#title' => t('Page compression'),
     '#default_value' => variable_get('page_compression', TRUE),
+    '#disabled' => !extension_loaded('zlib'),
     '#options' => array(t('Disabled'), t('Enabled')),
-    '#description' => t("By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. This option should be disabled when using a webserver that performs compression."),
+    '#description' => t('By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. This option should be disabled when using a webserver that performs compression. This option requires that the <a href="@url">PHP zlib extension</a> is enabled.', array('@url' => 'http://www.php.net/zlib')),
   );
 
   $form['block_cache'] = array(
     '#type' => 'fieldset',
     '#title' => t('Block cache'),
     '#description' => t('Enabling the block cache can offer a performance increase for all users by preventing blocks from being reconstructed on each page load. If the page cache is also enabled, performance increases from enabling the block cache will mainly benefit authenticated users.'),
   );
 
   $form['block_cache']['block_cache'] = array(
