Same name and namespace in other branches
  1. 6.x modules/system/system.admin.inc \system_performance_settings()
  2. 7.x modules/system/system.admin.inc \system_performance_settings()
1 string reference to 'system_performance_settings'
system_menu in modules/system/system.module
Implementation of hook_menu().

File

modules/system/system.module, line 652
Configuration system that lets administrators modify the workings of the site.

Code

function system_performance_settings() {
  $description = '<p>' . t("The normal cache mode is suitable for most sites and does not cause any side effects. The aggressive cache mode causes Drupal to skip the loading (init) and unloading (exit) of enabled modules when serving a cached page. This results in an additional performance boost but can cause unwanted side effects.") . '</p>';
  $problem_modules = array_unique(array_merge(module_implements('init'), module_implements('exit')));
  sort($problem_modules);
  if (count($problem_modules) > 0) {
    $description .= '<p>' . t('<strong class="error">The following enabled modules are incompatible with aggressive mode caching and might not function properly: %modules</strong>', array(
      '%modules' => implode(', ', $problem_modules),
    )) . '.</p>';
  }
  else {
    $description .= '<p>' . t('<strong class="ok">Currently, all enabled modules are compatible with the aggressive caching policy.</strong> Please note, if you use aggressive caching and enable new modules, you will need to check this page again to ensure compatibility.') . '</p>';
  }
  $form['page_cache'] = array(
    '#type' => 'fieldset',
    '#title' => t('Page cache'),
    '#description' => t('Enabling the cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time someone wants to view it.'),
  );
  $form['page_cache']['cache'] = array(
    '#type' => 'radios',
    '#title' => t('Caching mode'),
    '#default_value' => variable_get('cache', CACHE_DISABLED),
    '#options' => array(
      CACHE_DISABLED => t('Disabled'),
      CACHE_NORMAL => t('Normal (recommended, no side effects)'),
      CACHE_AGGRESSIVE => t('Aggressive (experts only, possible side effects)'),
    ),
    '#description' => $description,
  );
  $period = drupal_map_assoc(array(
    0,
    60,
    180,
    300,
    600,
    900,
    1800,
    2700,
    3600,
    10800,
    21600,
    32400,
    43200,
    86400,
  ), 'format_interval');
  $period[0] = t('none');
  $form['page_cache']['cache_lifetime'] = array(
    '#type' => 'select',
    '#title' => t('Minimum cache lifetime'),
    '#default_value' => variable_get('cache_lifetime', 0),
    '#options' => $period,
    '#description' => t('On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.'),
  );
  $form['bandwidth_optimizations'] = array(
    '#type' => 'fieldset',
    '#title' => t('Bandwidth optimizations'),
    '#description' => t('These options can help reduce both the size and number of requests made to your website. This can reduce the server load, the bandwidth used, and the average page loading time for your visitors.'),
  );
  $directory = file_directory_path();
  $is_writable = is_dir($directory) && is_writable($directory) && variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC;
  $form['bandwidth_optimizations']['preprocess_css'] = array(
    '#type' => 'radios',
    '#title' => t('Aggregate and compress CSS files'),
    '#default_value' => intval(variable_get('preprocess_css', FALSE) && $is_writable),
    '#disabled' => !$is_writable,
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t("Some Drupal modules include their own CSS files. When these modules are enabled, each module's CSS file adds an additional HTTP request to the page, which can increase the load time of each page. These HTTP requests can also slightly increase server load. It is recommended to only turn this option on when your site is in production, as it can interfere with theme development. This option is disabled if you have not set up your files directory, or if your download method is set to private."),
  );
  $form['#submit']['system_settings_form_submit'] = array();
  $form['#submit']['drupal_clear_css_cache'] = array();
  return system_settings_form($form);
}