function boost_is_cacheable in Boost 5
Same name and namespace in other branches
- 6 boost.module \boost_is_cacheable()
- 7 boost.module \boost_is_cacheable()
Determines whether a given Drupal page can be cached or not.
To avoid potentially troublesome situations, the user login page is never cached, nor are any admin pages. At present, we also refuse to cache any RSS feeds provided by Drupal, since they would require special handling in the mod_rewrite ruleset as they shouldn't be sent out using the text/html content type.
1 call to boost_is_cacheable()
- boost_init in ./
boost.module - Implementation of hook_init(). Performs page setup tasks.
File
- ./
boost.api.inc, line 20 - Implements the Boost API for static page caching.
Code
function boost_is_cacheable($path) {
$alias = drupal_get_path_alias($path);
$path = drupal_get_normal_path($path);
// normalize path
// Never cache the basic user login/registration pages or any administration pages
if ($path == 'user' || preg_match('!^user/(login|register|password)!', $path) || preg_match('!^admin!', $path)) {
return FALSE;
}
// At present, RSS feeds are not cacheable due to content type restrictions
if ($path == 'rss.xml' || preg_match('!/feed$!', $path)) {
return FALSE;
}
// Don't cache comment reply pages
if (preg_match('!^comment/reply!', $path)) {
return FALSE;
}
// Match the user's cacheability settings against the path
if (BOOST_CACHEABILITY_OPTION == 2) {
$result = drupal_eval(BOOST_CACHEABILITY_PAGES);
return !empty($result);
}
$regexp = '/^(' . preg_replace(array(
'/(\\r\\n?|\\n)/',
'/\\\\\\*/',
'/(^|\\|)\\\\<front\\\\>($|\\|)/',
), array(
'|',
'.*',
'\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
), preg_quote(BOOST_CACHEABILITY_PAGES, '/')) . ')$/';
return !(BOOST_CACHEABILITY_OPTION xor preg_match($regexp, $alias));
}