Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.59 diff -u -F^f -r1.59 bootstrap.inc --- includes/bootstrap.inc 29 Jul 2005 08:18:19 -0000 1.59 +++ includes/bootstrap.inc 29 Jul 2005 18:16:59 -0000 @@ -379,6 +379,16 @@ function cache_clear_all($cid = NULL, $w /** * Store the current page in the cache. + * + * We try to stored a gzipped version of the cache. This requires the + * PHP zlib extension (http://php.net/manual/en/ref.zlib.php). + * Presence of the extension is checked by testing for the function + * gzencode. There are two compression algorithms: gzip and deflate. + * The majority of all modern browsers supports gzip or both of them. + * We thus only deal with the gzip variant and unzip the cache in case + * the browser does not accept gzip encoding. + * + * @see drupal_page_header */ function page_set_cache() { global $user, $base_url; @@ -386,16 +396,23 @@ 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 = TRUE; if (function_exists('gzencode')) { - if (version_compare(phpversion(), '4.2', '>=')) { - $data = gzencode($data, 9, FORCE_GZIP); + // 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; } - else { - $data = gzencode($data, FORCE_GZIP); + else if (zlib_get_coding_type() == FALSE) { + $data = gzencode($data, 9, FORCE_GZIP); } + // The remaining case is 'gzip' which means the data is + // already compressed und nothing left to do but to store it. } ob_end_flush(); - cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers()); + if ($cache) { + cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers()); + } } } } @@ -569,6 +586,8 @@ function drupal_set_title($title = NULL) /** * Set HTTP headers in preparation for a page response. + * + * @see page_set_cache */ function drupal_page_header() { if (variable_get('cache', 0)) { @@ -879,4 +898,4 @@ function drupal_maintenance_theme() { $theme = ''; } -?> \ No newline at end of file +?>