You are here

function boost_init in Boost 7

Same name and namespace in other branches
  1. 5 boost.module \boost_init()
  2. 6 boost.module \boost_init()

Implements hook_init().

Performs page setup tasks.

File

./boost.module, line 243
Caches generated output as a static file to be served directly from the webserver.

Code

function boost_init() {
  global $_boost;
  $_boost = array();

  // Make sure the page is/should be cached according to our current configuration.
  // Start with the quick checks.
  if (strpos($_SERVER['SCRIPT_FILENAME'], 'index.php') === FALSE || $_SERVER['SERVER_SOFTWARE'] === 'PHP CLI' || $_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'HEAD' || isset($_GET['nocache']) || variable_get('maintenance_mode', 0) || defined('MAINTENANCE_MODE') || !empty($_SESSION['messages'])) {
    $_boost['cache_this'] = FALSE;
  }
  else {

    // More advanced checks.
    $_boost = boost_transform_url();
    if (empty($_boost['menu_item']['status']) || $_boost['menu_item']['status'] != 200) {
      $_boost['cache_this'] = FALSE;
    }
  }

  // Give modules a chance to alter the cookie handler callback used.
  // hook_boost_cookie_handler_callback_alter
  $cookie_handler_callback = 'boost_cookie_handler';
  drupal_alter('boost_cookie_handler_callback', $cookie_handler_callback);
  if (function_exists($cookie_handler_callback)) {
    $cookie_handler_callback();
  }
}