diff options
Diffstat (limited to 'includes/bootstrap.inc')
-rw-r--r-- | includes/bootstrap.inc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 7a4518a51..03e7755de 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -86,6 +86,14 @@ 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()) { + if (function_exists('gzencode')) { + if (version_compare(phpversion(), '4.2', '>=')) { + $data = gzencode($data, 9, FORCE_GZIP); + } + else { + $data = gzencode($data, FORCE_GZIP); + } + } cache_set(request_uri(), $data, 1, drupal_get_headers()); } } @@ -145,6 +153,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 |