function hook_emit_cache_max_age in Drupal 8 Cache Backport 7
Allows to react to emitting a cache max-age header.
Parameters
int $max_age: The maximum age to set or CACHE_MAX_AGE_PERMANENT.
1 function implements hook_emit_cache_max_age()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- d8cache_emit_cache_max_age in ./
d8cache.module - Implements hook_emit_cache_max_age().
1 invocation of hook_emit_cache_max_age()
File
- ./
d8cache.api.php, line 36 - API documentation for D8Cache.
Code
function hook_emit_cache_max_age($max_age) {
$page_cache_maximum_age = variable_get('page_cache_maximum_age', 0);
if ($max_age == CACHE_MAX_AGE_PERMANENT || $max_age > $page_cache_maximum_age) {
$max_age = $page_cache_maximum_age;
}
if (!isset($_COOKIE[session_name()])) {
header('Cache-Control', 'public, max-age=' . $max_age);
}
}