This project is not covered by Drupal’s security advisory policy.

Features

Attention: This module needs a core patch to work!
The core patch required for this module allows you to alter the page cache id and the page cache object.
The module uses this new functionality to provide the ability to:

  • Exclude paths from page caching
  • Use the same cache entry for http / https pages - url's are automatically rewritten to be protocol relative
  • Use custom cache expiration times
  • Use relative cache expiration times - e.g. tomorrow

Installation

  • Install as usual, see http://drupal.org/node/70151 for further information.
  • Apply core patch shipped with the module or manually change the core code
    according to the documentation of the changes in "Core Changes"
  • Enable page caching: admin/config/development/performance
    • Enable "Cache pages for anonymous users"
    • Configure the default cache lifetimes.

Core Changes

drupal_page_get_cache() in includes/bootstrap.inc

Original Code:

  $cache = cache_get($base_root . request_uri(), 'cache_page');

New Code:

    $cid = $base_root . request_uri();
    // Allow modules to alter the cid. We can't use the regular hook invocation
    // because this runs in the bootstrap.
    // @see bootstrap_invoke_all()
    // @see module_invoke()
    foreach (module_list() as $module) {
      if (module_hook($module, 'page_cache_cid_alter')) {
        call_user_func_array($module . '_page_cache_cid_alter', array(&$cid));
      }
    }
    $cache = cache_get($cid, 'cache_page');

drupal_page_set_cache() in includes/common.inc:

Original Code:

    $cache = (object) array(
      'cid' => $base_root . request_uri(),
      'data' => array(
        'path' => $_GET['q'],
        '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,
    );

New Code:

    $body = ob_get_clean();
    $cache = (object) array(
      'cid' => $base_root . request_uri(),
      'data' => array(
        'path' => $_GET['q'],
        'body' => $body,
        '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,
    );

FAQ

Q: Is it possible to cache the pages language dependent.
A: Yes it is, but you've to enable the language path prefix or the language subomain. This is the only way since the language negotiation happens later in the bootstrap - thus you can't add the language to the page cache cid.

Sponsored by Cando Image GmbH

Supporting organizations: 

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • Created by das-peter on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases