diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-07-08 19:22:48 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-07-08 19:22:48 +0000 |
commit | a0671877111ade392e699588c2efcbeaa139354b (patch) | |
tree | 57b2b6c00448c758c1334811ec9abf2094be2a7d /includes | |
parent | 56fa37cb8ed145e83a639fb45ac96fb399cad1b0 (diff) | |
download | brdo-a0671877111ade392e699588c2efcbeaa139354b.tar.gz brdo-a0671877111ade392e699588c2efcbeaa139354b.tar.bz2 |
- Patch #8509 by Killes and Steven: added support for sending compressed
pages. Useful to reduce your site's bandwidth.
Diffstat (limited to 'includes')
-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 |