function esi_set_page_cache in ESI: Edge Side Includes 6.2
2 calls to esi_set_page_cache()
- esi__block_handler in ./
esi.module - Menu handler for ESIs
- esi__panel_pane_handler in ./
esi.module - Menu handler to serve individual panel-panes via ESI.
File
- ./
esi.module, line 743 - Adds support for ESI (Edge-Side-Include) integration, allowing blocks to be\ delivered by ESI, with support for per-block cache times.
Code
function esi_set_page_cache($data, $scope, $last_arg) {
global $base_root;
if (!variable_get('esi_page_cache', ESI_PAGE_CACHE)) {
return FALSE;
}
if (!variable_get('esi_mode', ESI_MODE)) {
return FALSE;
}
require_once drupal_get_path('module', 'esi') . '/esi.inc';
switch ($scope) {
// Disabled or not cached.
case 0:
case 1:
return FALSE;
break;
// Global or page.
case 2:
case 3:
break;
// User level.
case 4:
case 5:
case 6:
case 7:
// Cache only if the last argument of the URL contains CACHE=*.
if (strpos($last_arg, 'CACHE=') !== 0) {
return FALSE;
}
break;
}
if (variable_get('page_compression', TRUE) && extension_loaded('zlib')) {
$data = gzencode($data, 9, FORCE_GZIP);
}
if (_esi_get_drupal_distribution() !== 'drupal') {
$cache = (object) array(
'cid' => 'esi:' . $base_root . request_uri(),
'data' => $data,
'expire' => CACHE_TEMPORARY,
'created' => $_SERVER['REQUEST_TIME'],
'headers' => array(),
);
// Restore preferred header names based on the lower-case names returned
// by drupal_get_header().
$header_names = _drupal_set_preferred_header_name();
foreach (drupal_get_header() as $name_lower => $value) {
$cache->headers[$header_names[$name_lower]] = $value;
}
return cache_set($cache->cid, $cache->data, 'cache_page', $cache->expire, serialize($cache->headers));
}
else {
return cache_set('esi:' . $base_root . request_uri(), $data, 'cache_page', CACHE_TEMPORARY, drupal_get_headers());
}
}