You are here

function _prod_check_page_compression in Production check & Production monitor 6

Same name and namespace in other branches
  1. 7 prod_check.module \_prod_check_page_compression()

File

./prod_check.module, line 960

Code

function _prod_check_page_compression($caller = 'internal') {
  $check = array();
  $status = TRUE;
  $title = 'Page compression';
  $path = 'admin/settings/performance';
  if ($caller != 'internal') {
    $path = PRODCHECK_BASEURL . $path;
  }

  // Adjust path if Boost is enabled.
  if (variable_get('boost_enabled', 0) == 1) {
    $path .= '/boost';
  }
  if (variable_get('page_compression', 0) == 0) {
    $status = FALSE;

    // When using Varnish, turning off page compression is a good thing!
    if (module_exists('varnish')) {
      $status = TRUE;
    }

    // Check if server is already handling compression, in which case the
    // setting also should be off.
    if (function_exists('ob_gzhandler') && ini_get('zlib.output_compression')) {
      $status = TRUE;
    }
  }
  $check['prod_check_page_compression'] = array(
    '#title' => t($title),
    '#state' => $status,
    '#severity' => $caller == 'nagios' ? NAGIOS_STATUS_CRITICAL : PROD_CHECK_REQUIREMENT_ERROR,
    '#value_ok' => t('Enabled'),
    '#value_nok' => t('Disabled'),
    '#description_ok' => prod_check_ok_title($title, $path),
    '#description_nok' => t('Your !link settings are disabled. You should enable page compression on production sites!', prod_check_link_array($title, $path)),
    '#nagios_key' => 'PCOMP',
    '#nagios_type' => 'state',
  );
  return prod_check_execute_check($check, $caller);
}