Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ajax Cache backed by jStorage for jQuery

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 jquery-ajax-jstorage-cache.js
Octocat-spinner-32 jquery-ajax-jstorage-cache.min.js
README.md

About

jquery-ajax-jstorage-cache is a plugin build for jQuery (>1.5.1) and jStorage . It's a client-side cache plugin for AJAX response intended to save bandwith and time. All the responses are stored in the Local Storage powered by HTML5 (see jStorage#Support).

How to use

Parameters

$.ajax({
    url: '/post',

    cacheJStorage: true,
    cacheKey: 'post',
    cacheTTL: 60,
    isCacheValid: function(){
        return true;
    },

    success: function(reply) {
        // i can play with my reply ! 
    }
});

On your AJAX request you got 4 new parameters :

  • cacheJStorage
    • Turn cacheJStorage on/off
    • Default: false
  • cacheTTL
    • Invalid cache after a certain time
    • In seconds
    • Deault: none ( persistant in cache )
  • cacheKey
    • CacheKey is the key that will be used to store the response in jStorage. It allow you to delete your cache easily with the jStorage.removeKey() function.
    • Default: URL + TYPE(GET/POST) + DATA
  • isCacheValid
    • This function must return true or false. On false, the cached response is removed.
    • Default: null

Notes

  • You can delete the cache by using jStorage API (see jStorage#Usage).
  • Note that you can pre-load content with this plugin. You just have do to the same AJAX request without a success callback and the same cacheKey.

License

This project is distributed under Apache 2 License. See LICENSE.txt for more information.

Something went wrong with that request. Please try again.