pantheon_advanced_page_cache.module in Pantheon Advanced Page Cache 7
Main module file for the Pantheon Advanced Page Cache.
File
pantheon_advanced_page_cache.moduleView source
<?php
/**
* @file
* Main module file for the Pantheon Advanced Page Cache.
*/
/**
* Implements hook_pre_emit_cache_tags_alter().
*/
function pantheon_advanced_page_cache_pre_emit_cache_tags_alter(&$tags) {
// Rename all _list cache tags to _emit_list to avoid clearing list tags by
// default.
if (variable_get('pantheon_advanced_page_cache_override_list_tags', TRUE)) {
foreach ($tags as $key => $tag) {
$tags[$key] = str_replace('_list', '_emit_list', $tag);
}
}
}
/**
* Implements hook_emit_cache_tags().
*/
function pantheon_advanced_page_cache_emit_cache_tags($tags) {
$tags_string = implode(' ', $tags);
if (25000 < strlen($tags_string)) {
$tags_string = substr($tags_string, 0, 25000);
// The string might have cut of in the middle of a tag.
// So now find the the last occurence of a space and cut to that length.
$tags_string = substr($tags_string, 0, strrpos($tags_string, ' '));
watchdog('pantheon_advanced_page_cache', 'More cache tags were present than could be passed in the Surrogate-Key HTTP Header due to length constraints. To avoid a 502 error the list of surrogate keys was trimmed to a maximum length of 25,000 bytes. Since keys beyond the 25,000 maximum were removed this page will not be cleared from the cache when any of the removed keys are cleared (usually by entity save operations) as they have been stripped from the surrogate key header. See https://www.drupal.org/project/pantheon_advanced_page_cache/issues/2973861 for more information about how you can filter out redundant or unnecessary cache metadata.', array(), WATCHDOG_WARNING);
}
drupal_add_http_header('Surrogate-Key', $tags_string);
}
/**
* Implements hook_invalidate_cache_tags().
*/
function pantheon_advanced_page_cache_invalidate_cache_tags($tags) {
if (function_exists('pantheon_clear_edge_keys')) {
pantheon_clear_edge_keys($tags);
}
}
Functions
Name![]() |
Description |
---|---|
pantheon_advanced_page_cache_emit_cache_tags | Implements hook_emit_cache_tags(). |
pantheon_advanced_page_cache_invalidate_cache_tags | Implements hook_invalidate_cache_tags(). |
pantheon_advanced_page_cache_pre_emit_cache_tags_alter | Implements hook_pre_emit_cache_tags_alter(). |