4.6.x bootstrap.inc page_set_cache()
4.7.x common.inc page_set_cache()
5.x common.inc page_set_cache()
6.x common.inc 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


1 call to page_set_cache()
drupal_page_footer in includes/common.inc
Perform end-of-request tasks.


includes/common.inc, line 2777
Common functions that many Drupal modules will need to reference.


function page_set_cache() {
  global $user, $base_root;
  if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && page_get_cache(TRUE)) {

    // This will fail in some cases, see page_get_cache() for the explanation.
    if ($data = ob_get_contents()) {
      if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
        $data = gzencode($data, 9, FORCE_GZIP);
      cache_set($base_root . request_uri(), $data, 'cache_page', CACHE_TEMPORARY, drupal_get_headers());