summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc2
-rw-r--r--includes/common.inc9
2 files changed, 9 insertions, 2 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 7a4493991..5511d7c5d 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -1278,7 +1278,7 @@ function drupal_page_header() {
*/
function drupal_serve_page_from_cache(stdClass $cache) {
// Negotiate whether to use compression.
- $page_compression = variable_get('page_compression', TRUE) && extension_loaded('zlib');
+ $page_compression = !empty($cache->data['page_compressed']);
$return_compressed = $page_compression && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE;
// Get headers set in hook_boot(). Keys are lower-case.
diff --git a/includes/common.inc b/includes/common.inc
index 9cd73f4e2..38895c542 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -5176,6 +5176,10 @@ function drupal_page_set_cache() {
global $base_root;
if (drupal_page_is_cacheable()) {
+
+ // Check whether the current page might be compressed.
+ $page_compressed = variable_get('page_compression', TRUE) && extension_loaded('zlib');
+
$cache = (object) array(
'cid' => $base_root . request_uri(),
'data' => array(
@@ -5183,6 +5187,9 @@ function drupal_page_set_cache() {
'body' => ob_get_clean(),
'title' => drupal_get_title(),
'headers' => array(),
+ // We need to store whether page was compressed or not,
+ // because by the time it is read, the configuration might change.
+ 'page_compressed' => $page_compressed,
),
'expire' => CACHE_TEMPORARY,
'created' => REQUEST_TIME,
@@ -5200,7 +5207,7 @@ function drupal_page_set_cache() {
}
if ($cache->data['body']) {
- if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
+ if ($page_compressed) {
$cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP);
}
cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire);