Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.68 diff -u -p -r1.68 bootstrap.inc --- includes/bootstrap.inc 19 Sep 2005 19:13:35 -0000 1.68 +++ includes/bootstrap.inc 9 Oct 2005 21:27:47 -0000 @@ -380,6 +380,16 @@ function cache_clear_all($cid = NULL, $w /** * Store the current page in the cache. + * + * We try to store a gzipped version of pages in the cache. This + * requires the PHP zlib module (http://php.net/manual/en/ref.zlib.php). + * Presence of this module 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 only save gzipped data in the cache, or uncompressed data if + * zlib is not available. + * + * @see drupal_page_header */ function page_set_cache() { global $user, $base_url; @@ -388,15 +398,15 @@ function page_set_cache() { // This will fail in some cases, see page_get_cache() for the explanation. if ($data = ob_get_contents()) { if (function_exists('gzencode')) { - if (version_compare(phpversion(), '4.2', '>=')) { + if (zlib_get_coding_type() == 'gzip') { $data = gzencode($data, 9, FORCE_GZIP); } - else { - $data = gzencode($data, FORCE_GZIP); - } } ob_end_flush(); - cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers()); + if ($data) { + // May be false if gzencode returned an error + cache_set($base_url . request_uri(), $data, CACHE_TEMPORARY, drupal_get_headers()); + } } } } @@ -569,6 +579,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)) {