1 admin_bar.module | admin_bar_js_cache() |
Menu callback; Output administration bar for HTTP caching via AJAX request.
See also
File
- core/
modules/ admin_bar/ admin_bar.module, line 380 - Render an administrative bar as a dropdown menu at the top of the window.
Code
function admin_bar_js_cache() {
global $conf;
// Enforce page caching.
$conf['cache'] = 1;
backdrop_page_is_cacheable(TRUE);
// If we have a cache, serve it.
// @see _backdrop_bootstrap_page_cache()
$cache = backdrop_page_get_cache();
if (is_object($cache)) {
backdrop_add_http_header('X-Backdrop-Cache', 'HIT');
backdrop_serve_page_from_cache($cache);
exit;
}
// Otherwise, create a new page response (that will be cached).
backdrop_add_http_header('X-Backdrop-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 Backdrop page).
$max_age = 3600 * 24 * 365;
backdrop_add_http_header('Expires', gmdate(DATE_RFC1123, REQUEST_TIME + $max_age));
backdrop_add_http_header('Cache-Control', 'private, max-age=' . $max_age);
// Retrieve and return the rendered menu.
module_load_include('inc', 'admin_bar');
return admin_bar_output();
}