How to enable caching for ajax callbacks, especially for colorbox node? I am using colorbox node module on my site, and it looks like the ajax callbacks for rendering the node are not cached at all. Tested it with a simple snippet in the node template:

&lt;div&gt;generated on &lt;?php $dt=new DateTime();print $dt-&gt;format('d.m.Y H:i:s');?&gt;&lt;/div&gt;


Colorbox is using a custom display, to have a custom node.tpl

function mytheme_preprocess_node(&amp;$vars) {
  if ($vars['node']-&gt;type == 'my_content_type' &amp;&amp; $vars['view_mode'] == 'colorbox') {
    $vars['theme_hook_suggestions'][] = 'node__my_content_type__colorbox';
  }
}


Caching for anonymous user is turned on and works for node pages.

is this issue related to colorbox node (e.g. missing caching implementation in colorbox node) or some other module?

I dived into the code of colorbox node and found out that the click on a colorbox link will be rewritten and rerouted through this menu:

/*
 * Implements hook_menu().
 */
function colorbox_node_menu() {
  $items['colorbox/%colorbox_node_url'] = array(
    'page callback' =&gt; 'colorbox_node_output',
    'page arguments' =&gt; array(1),
    'access arguments' =&gt; array('access content'),
    'load arguments' =&gt; array('%map'),
    'delivery callback' =&gt; 'ajax_deliver',
    'theme callback' =&gt; 'ajax_base_page_theme',
    'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}


is there a way to cache 'delivery callback' =&gt; 'ajax_deliver', without hacking the colorbox_node_output() function? Whats the best practice here to get this into caching? I think implementing a cache inside colorbox_node_output() might already be too late because it is running through the complete bootstrap process before executing that function.
This can be done. Will require 2 hooks hook_menu_alter() &amp; hook_boot() and some non trivial code.

Top level overview of how to do this:
Use hook_menu_alter() to call a wrapper around colorbox_node_output() that will cache its output. Use hook_boot() to check the cache and deliver the cached content, routing the cached content though ajax_deliver().

An example of cache code flow can be seen in the 6.x-2.x ESI module. esi_get_page_cache() gets called from esi_boot. esi_set_page_cache() is what sets the cache; you can see it getting called at the bottom of these functions: esi__block_handler() &amp; esi__panel_pane_handler(). Side note: A big reason the ESI module's cache code has a lot of complexity is it's compatible with D6 core and Pressflow; both have different code for the page cache.