Wednesday, June 25, 2014

JavaScript: Easy way to Cache objects in Local Storage/ Client Browser in JavaScript

Here is a easy way to store and retrieve  your java script objects ( even more than 4KB) in the local /Client browser . I'm using jStorage for this method and jStorage supports storing Strings, Numbers, JavaScript objects, Arrays and even native XML nodes. jStorage also supports setting TTL values for auto expiring stored keys and - best of all - notifying other tabs/windows when a key has been changed or publishing/subscribing to events from the same or another tab/window, which makes jStorage also a local PubSub platform for web applications.

 < script src="">
< script src="http//">
< script src="jstorage.js">

< script type="text/javascript">
var testObject = "test123"; /* Sample Data. You can fetch the objects from Server and store it*/

// Check if "key" exists in the storage
var value = $.jStorage.get("key");
< /script >

Here you go, Now its easy to store to the cache with bigger data. hope this helps.
Article Source and .js file available at :

Happy Browsing!

No comments:

Post a Comment