You are here

function boost_async_opp in Boost 6

Output text & set php in async mode.

Parameters

$output: string - Text to output to open connection.

$wait: bool - Wait 1 second?

$content_type: string - Content type header.

4 calls to boost_async_opp()
boost_crawler_run in ./boost.module
The brains of the crawler.
boost_stats_ajax_callback in stats/boost_stats.ajax.inc
AJAX Menu Callback.
boost_views_async in ./boost.module
Run views looking for new nodes.
_boost_ob_handler in ./boost.module
PHP output buffering callback for static page caching.

File

./boost.module, line 6033
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_async_opp($output, $wait = TRUE, $content_type = "text/html; charset=utf-8", $length = 0) {
  if (headers_sent()) {
    return FALSE;
  }

  // Calculate Content Length
  if ($length == 0) {
    $output .= "\n";
    $length = boost_strlen($output) - 1;
  }

  // Prime php for background operations
  $loop = 0;
  while (ob_get_level() && $loop < 25) {
    ob_end_clean();
    $loop++;
  }
  header("Connection: close");
  ignore_user_abort();

  // Output headers & data
  ob_start();
  header("Content-type: " . $content_type);
  header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
  header("Cache-Control: no-cache");
  header("Cache-Control: must-revalidate");
  header("Content-Length: " . $length);
  header("Connection: close");
  print $output;
  ob_end_flush();
  flush();

  // wait for 1 second
  if ($wait) {
    sleep(1);
  }

  // text returned and connection closed.
  // Do background processing. Time taken after should not effect page load times.
  return TRUE;
}