jCache - A client side jQuery cache plugin
jCache is a plugin made on the idea of a client-side Hashtable (key-value pairs).
Usually to improve web apps performance, you make calls to the server to get data and cache them on the server. This is of course effective, but sometimes not enough, since the browser must wait for the response from server none the less.
Using jCache, the data will be saved into browser's memory and ready to be retrieved later via a key (a good candidate for keys is the ajax URL, for example "products/getProducts.php?start=5&end=10", since it is unique for each cached item). Before any AJAX GET request, a cache check should be made, and if the data is there already, then it should be used without any need to query the server again. This will be lightning fast!
A max number of cached items should be set (default is 10) to prevent browser's lack of memory - though normally this won't likely to happen, except you're handling a huge AJAX application like Flickr or Gmail ;) When the cache exceeds that threshold, the oldest item will be cleared first.
The usage of jCache is just example as this:
1. Include this plugin into your web document after jQuery:
<script type="text/javascript" src="js/jquery.jcache.js"></script>
2. [OPTIONAL] Set the max cached item number, for example 20
$.jCache.maxSize = 20;
3. Start playing around with it:
- Put an item into cache:
$.jCache.setItem(theKey, the Value);
- Retrieve an item from cache:
var theValue = $.jCache.getItem(theKey);
Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 1.0.2 | 2007-Nov-09 | 3.04 KB | Recommended for 1.0.x | ||