Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
jquery plugin to cache ajax request and more.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
assets
templates
testcases
README
jquery.cacheAjax.js
server.rb

README

= jQuery.cacheAjax 

== How to use?

=== $.cacheAjax
    $.cacheAjax() is a drop-in replacement for $.ajax().

    but what make it special ? the following:
      cache your ajax requests:
        oops,of course!
      force a new ajax request:
        $.cacheAjax({ force : true })
      customize cache key ( default use 'url + data' )
        $.cacheAjax({ key : customized_key })
      set timeout:
        set timeout for each request:
          $.cacheAjax({ timeout : 2000 }) // 2 seconds
        set global timeout:
          $.setCacheTimeout(2000)     // 2 seconds
          $.setCacheTimeout(false)    // never expire

=== $.expireCache
  $.expireCache(/regexp/)
    expire all key match /regexp/

  $.expireCache('string-key')
    expire 'string-key'

  $.expireCache()
    default expire `document.location.hash`,use the following to reset the default:
      $.setCacheDefaultKey('string');
        // use 'string' as default
      $.setCacheDefaultKey(function(){});
        // use the function's return value as default

=== A small sample:
  $.cacheAjax({
    url : '/pictures'
    dataType: 'script'
    success: function(e){
      console.log(e);
    },
    force : true,
    key : 'customized_key',
    timeout : 2000
  });

  $.expireCache(/album\/\d+\/picture(s)?/);

== How To Run Test ?
  $ sudo gem install sinatra
  $ ruby server.rb
  $ open '127.0.0.1:4567' in browser


Copyright (c) 2009  Dual licensed under the MIT and GPL
  Author : Jinzhu Zhang
  Github : http://github.com/jinzhu
  Email  : wosmvp (no-spam) gmail (no-spam) com
Something went wrong with that request. Please try again.