You are here

function ajaxblocks_page_cacheable in Ajax Blocks 7

Same name and namespace in other branches
  1. 6 ajaxblocks.module \ajaxblocks_page_cacheable()

Returns TRUE if current page will be cached (for anonymous or for authenticated users) by Drupal core or by contrib modules (boost and authcache are supported).

1 call to ajaxblocks_page_cacheable()
ajaxblocks_preprocess_block in ./ajaxblocks.module
Implements hook_preprocess_block().

File

./ajaxblocks.module, line 297
Loads dynamic blocks on cached page for anonymous users by performing AJAX request.

Code

function ajaxblocks_page_cacheable() {
  static $page_cacheable = NULL;
  if (!is_null($page_cacheable)) {
    return $page_cacheable;
  }
  if (!drupal_page_is_cacheable()) {
    $page_cacheable = FALSE;
    return $page_cacheable;
  }
  if (module_exists('boost') && isset($GLOBALS['_boost']) && isset($GLOBALS['_boost']['cache_this']) && $GLOBALS['_boost']['cache_this']) {

    //TODO check 403 and 404 for Boost: boost_get_http_status 403 404 for anon -> uncached
    $page_cacheable = TRUE;
    return $page_cacheable;
  }
  if (module_exists('authcache') && isset($GLOBALS['is_page_authcache']) && $GLOBALS['is_page_authcache']) {

    //TODO check 403 and 404 for authcache:  (variable_get('authcache_http200', FALSE) && _authcache_get_http_status() != 200)
    $page_cacheable = TRUE;
    return $page_cacheable;
  }
  $page_cacheable = $GLOBALS['user']->uid == 0 && variable_get('cache', 0);
  return $page_cacheable;
}