function boost_expire_cache in Boost 7
Implements hook_expire_cache (from the 'expire' module)
File
- ./
boost.module, line 426 - Caches generated output as a static file to be served directly from the webserver.
Code
function boost_expire_cache($urls, $wildcards, $object_type, $object) {
global $base_root;
foreach ($urls as $key => $url) {
// Decode the url since it may have a query string that has been encoded.
$boost = boost_transform_url(urldecode($url));
// We need the extension for the filename.
$boost['header_info'] = boost_get_header_info();
$boost['matched_header_info'] = boost_match_header_attributes($boost['header_info']);
// Issue #2135835 Cache may not be enabled for this type (html/xml/ajax)
if (!$boost['matched_header_info']['enabled']) {
continue;
}
// If wildcards are enabled, we'll need to create a wildcard pattern for globbing
if ($wildcards[$key]) {
$pattern = isset($boost['filename']) ? $boost['filename'] . '*.' . $boost['matched_header_info']['extension'] : NULL;
}
else {
$pattern = isset($boost['filename']) ? $boost['filename'] . '.' . $boost['matched_header_info']['extension'] : NULL;
}
// Remove the files.
$files = glob($pattern, GLOB_NOSORT);
if ($files) {
foreach ($files as $filename) {
if (unlink($filename)) {
boost_log('Removed !file from the boost cache.', array(
'!file' => $filename,
), WATCHDOG_DEBUG);
}
else {
boost_log('Could not delete the cache for !url, file !file does not exist.', array(
'!url' => $url,
'!file' => $filename,
), WATCHDOG_DEBUG);
}
}
}
}
}