function _acquia_purge_get_diagnosis_page_cache_age in Acquia Purge 6
Test if the page_cache_max_age setting is configured in a healthy way.
@returns Associative array with the following elements:
- title: The name of the requirement.
- value: The current value (e.g., version, time, level, etc).
- description: The description of the requirement/status.
- severity: ACQUIA_PURGE_SEVLEVEL_INFO, _OK, _WARNING, _ERROR
Parameters
string $t: Name of the t() function to call.
File
- ./
acquia_purge.diagnostics.inc, line 256 - Self-test diagnostic test functions for _acquia_purge_get_diagnosis().
Code
function _acquia_purge_get_diagnosis_page_cache_age($t) {
$pressflow = function_exists('drupal_page_cache_header_external');
$age = (int) variable_get('page_cache_max_age', 0);
$test = array(
'title' => $t('Page cache maximum age'),
);
// Set the value label.
$test['value'] = $t('Disabled');
if ($age !== 0) {
$test['value'] = array(
'@age' => round($age / 60 / 60, 2),
);
$test['value'] = $t('@age hours', $test['value']);
}
// Determine what "find out more" link we can provide.
$link = 'http://blog.merge.nl/20120118/how-does-caching-work-drupal';
if (user_access('administer site configuration') && $pressflow) {
$link = url('admin/settings/performance');
}
// Users without a TTL configured won't put our module to much use.
if ($age === 0) {
$test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
$test['description'] = $t('The "<a href="!link" target="_blank">Page cache' . ' maximum age</a>"-setting of your website is disabled, while we' . ' strongly recommend to put it to 6 hours or longer in combination with' . ' the Acquia Purge module. The setting determines how long external' . ' caches (like our load balancers) are instructed to keep a cached copy' . ' of content. With your current setting your load balancer is not being' . ' used and your web servers will likely be under constant stress,' . ' causing a slow site and system resources being wasted.', array(
'!link' => $link,
));
}
elseif ($age < 21600) {
$test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
$test['description'] = $t('The "<a href="!link" target="_blank">page cache' . ' maximum age</a>"-setting of your website is set to @age, while we' . ' strongly recommend to put it to 6 hours or longer in combination with' . ' the Acquia Purge module. The setting determines how long external' . ' caches (like our load balancers) are instructed to keep a cached copy' . ' of content. With your current configuration, your load balancer is not' . ' used effectively and your web servers will likely be under stress,' . ' causing a slow site and system resources being wasted.', array(
'!link' => $link,
'@age' => $test['value'],
));
}
else {
$test['severity'] = ACQUIA_PURGE_SEVLEVEL_OK;
}
return $test;
}