You are here

function authcache_debug_info_ajax_get in Authenticated User Page Caching (Authcache) 7.2

Deliver cache info to the client via Ajax/Drupal.settings.

1 string reference to 'authcache_debug_info_ajax_get'
authcache_debug_menu in modules/authcache_debug/authcache_debug.module
Implements hook_menu().

File

modules/authcache_debug/authcache_debug.module, line 331
Debug widget for Authcache.

Code

function authcache_debug_info_ajax_get($data) {
  if (!empty($_SESSION['aucdbg_precluded'])) {
    foreach ($_SESSION['aucdbg_precluded'] as $message) {
      $data['messages'][] = $message;
    }
    unset($_SESSION['aucdbg_precluded']);
    if (empty($_SESSION)) {
      unset($_SESSION);
    }
    if (empty($data['cacheStatus'])) {
      $data['cacheStatus'] = 'Request PRECLUDED';
    }
  }
  if (empty($data['cacheStatus'])) {
    $req_id = empty($_COOKIE['Drupal_authcache_aucdbg']) ? '' : $_COOKIE['Drupal_authcache_aucdbg'];
    $cache_req_id = $data['cacheReqId'];
    $data['cacheStatus'] = $req_id === $cache_req_id ? 'MISS' : 'HIT';
  }
  drupal_add_http_header('Vary', 'Cookie');
  drupal_add_http_header('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0');
  drupal_json_output($data);
  drupal_exit();
}