function admin_menu_js_cache

nittany7 admin_menu.module admin_menu_js_cache()
cis7 admin_menu.module admin_menu_js_cache()
mooc7 admin_menu.module admin_menu_js_cache()

Menu callback; Output administration menu for HTTP caching via AJAX request.

See also

admin_menu_deliver()

2 string references to 'admin_menu_js_cache'
admin_menu_js in modules/contrib/admin_menu/admin_menu.module
Implements hook_js().
admin_menu_menu in modules/contrib/admin_menu/admin_menu.module
Implements hook_menu().

File

modules/contrib/admin_menu/admin_menu.module, line 332
Render an administrative menu as a dropdown menu at the top of the window.

Code

function admin_menu_js_cache() {
  global $conf;

  // Suppress Devel module.
  $GLOBALS['devel_shutdown'] = FALSE;

  // Enforce page caching.
  $conf['cache'] = 1;
  drupal_page_is_cacheable(TRUE);

  // If we have a cache, serve it.
  // @see _drupal_bootstrap_page_cache()
  $cache = drupal_page_get_cache();
  if (is_object($cache)) {
    header('X-Drupal-Cache: HIT');
    // Restore the metadata cached with the page.
    $_GET['q'] = $cache->data['path'];
    date_default_timezone_set(drupal_get_user_timezone());

    drupal_serve_page_from_cache($cache);

    // We are done.
    exit;
  }

  // Otherwise, create a new page response (that will be cached).
  header('X-Drupal-Cache: MISS');

  // The Expires HTTP header is the heart of the client-side HTTP caching. The
  // additional server-side page cache only takes effect when the client
  // accesses the callback URL again (e.g., after clearing the browser cache or
  // when force-reloading a Drupal page).
  $max_age = 3600 * 24 * 365;
  drupal_add_http_header('Expires', gmdate(DATE_RFC1123, REQUEST_TIME + $max_age));
  drupal_add_http_header('Cache-Control', 'private, max-age=' . $max_age);

  // Retrieve and return the rendered menu.
  return admin_menu_output();
}