drupal_page_set_cache
- Versions
- 7
drupal_page_set_cache()
Store the current page in the cache.
If page_compression is enabled, a gzipped version of the page is stored in the cache to avoid compressing the output on each request. The cache entry is unzipped in the relatively rare event that the page is requested by a client without gzip support.
Page compression requires the PHP zlib extension (http://php.net/manual/en/ref.zlib.php).
See also
drupal_page_header
Code
includes/common.inc, line 4529
<?php
function drupal_page_set_cache() {
global $base_root;
if (drupal_page_is_cacheable()) {
$cache = (object) array(
'cid' => $base_root . request_uri(),
'data' => ob_get_clean(),
'expire' => CACHE_TEMPORARY,
'created' => REQUEST_TIME,
'headers' => array(),
);
// Restore preferred header names based on the lower-case names returned
// by drupal_get_http_header().
$header_names = _drupal_set_preferred_header_name();
foreach (drupal_get_http_header() as $name_lower => $value) {
$cache->headers[$header_names[$name_lower]] = $value;
}
if ($cache->data) {
if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
$cache->data = gzencode($cache->data, 9, FORCE_GZIP);
}
cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire, $cache->headers);
}
return $cache;
}
}
?>Login or register to post comments 