AJAX Cache

This project is not covered by Drupal’s security advisory policy.

AJAX Cache acts much like imagecache by generating the result of a request on demand and storing it on the filesystem for later reuse. This is useful if you are trying to scale a site that makes many dynamic ajax calls. AJAX cache saves results directly to the files so the web server can serve them directly, rather then bootstrapping Drupal.

AJAX Cache will do nothing by itself. Supporting code must call it.

How to use

First you define the presets you are going to use like this:

 * Test implementation of hook_ajaxcache_presets().
function ajaxcache_ajaxcache_presets() {
  return array(
    'test' => array(
      // Name of your function that outputs the data to be cached
      'callback' => 'ajaxcache_test_callback',

      // Optional: include file where the callback is located.
      // 'file' => 'include.inc',

      // Optional: file extension to be used when serving the file. Defaults to html.
      // 'extension' => 'json',

      // Optional: file name (without extension) to be used when serving the file. Defaults to ajax.
      // 'filename' => 'test',

Then, instead of passing javascript the URL that would point to your output function through the menu system, you pass the URL returned by:

ajaxcache_get_url($preset_name, $args);

where $preset_name is the name set in your hook_ajaxcache_presets implementation and $args are the arguments passed to your callback function.




- Has the same caching benefits without a need to change your code to use the AJAX Cache API.
- Built in expiration logic.
- Very popular caching module (more support).
- Provides caching for many content types (html, css, js, etc)


- Doesn't work for authenticated users
- Need to change your .htaccess
- Heavyweight if all you want is to cache AJAX.
- You'll have to implement your own menu callbacks and argument handling.

Originally written by Roger López and contributed by Sony Music

AJAX Cache项目的Drush安装命令:复制到剪贴板