You are here

function _acquia_purge_diagnostics_page_caching_time_ttl in Acquia Purge 7

Page caching time (TTL).

Parameters

string $t: Name of the t() function to call.

AcquiaPurgeService $service: The Acquia Purge service.

Return value

array Associative array with the following elements:

1 string reference to '_acquia_purge_diagnostics_page_caching_time_ttl'
acquia_purge_acquia_purge_diagnostics in ./acquia_purge.module
Implements hook_acquia_purge_diagnostics().

File

./acquia_purge.diagnostics.inc, line 798
Diagnostic self-tests and reports that aim to prevent runtime misery.

Code

function _acquia_purge_diagnostics_page_caching_time_ttl($t, $service) {
  $age = (int) variable_get('page_cache_maximum_age', 0);
  $test = array(
    'title' => $t('Page caching time (TTL)'),
  );

  // 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 (function_exists('user_access')) {
    if (function_exists('user_access') && user_access('administer site configuration')) {
      $link = url('admin/config/development/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">expiration' . ' of cached pages</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">expiration' . ' of cached pages</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;
}