You are here

function _boost_ob_handler in Boost 5

Same name and namespace in other branches
  1. 6 boost.module \_boost_ob_handler()

PHP output buffering callback for static page caching.

NOTE: objects have already been destructed so $user is not available.

1 string reference to '_boost_ob_handler'
boost_init in ./boost.module
Implementation of hook_init(). Performs page setup tasks.

File

./boost.module, line 303
Provides static page caching for Drupal.

Code

function _boost_ob_handler($buffer) {

  // Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here.
  chdir(dirname($_SERVER['SCRIPT_FILENAME']));

  // Check the currently set content type; at present we can't deal with anything else than HTML.
  if (_boost_get_content_type() == 'text/html' && _boost_get_http_status() == 200) {
    if (strlen($buffer) > 0) {

      // Sanity check
      boost_cache_set($GLOBALS['_boost_path'], $buffer);
    }
  }

  // Allow the page request to finish up normally
  return $buffer;
}