function ape_page_delivery_callback_alter in Advanced Page Expiration 7
Implements hook_page_delivery_callback_alter().
Set an exception length cache-control, or if no match set a global value.
File
- ./
ape.module, line 105 - Allows finer control of the Cache Control header.
Code
function ape_page_delivery_callback_alter(&$callback) {
$max_age = ape_cache_set();
// Check to see if another module or hook has already set an APE header. This
// allows rules or other module integration to take precedent.
if (is_null($max_age)) {
if (ape_check_path(variable_get('ape_alternatives', ''), $_GET['q'])) {
$max_age = variable_get('ape_alternative_lifetime', 0);
}
else {
$max_age = variable_get('page_cache_maximum_age', 0);
}
}
$router_item = menu_get_item();
// If 404, set to 404 configurable value.
if ($router_item == FALSE) {
$max_age = variable_get('ape_404_lifetime', 0);
}
elseif ($router_item['access'] == FALSE) {
$max_age = 0;
}
// Allow max_age to be altered by hook_ape_cache_alter().
$original_max_age = $max_age;
drupal_alter('ape_cache_expiration', $max_age, $original_max_age);
ape_set_cache_header($max_age);
}