If you are caching private information you are going to have a bad time. The expiration feature is misleading. It will only run when the site with the library is loaded.<p>So if you're in a random internet café checking your email on a site that uses this library to cache your emails and then close the browser and leave all that private information, your email content, is cached on that browser. If a savvy enough person saw you on this site and knew what it did that individual could go to the browser and simply use Web Inspector, in the case of Chrome, and check out what was cached and read all of your cached emails.<p>There is no way for the client to know it's not a secure environment unless you ask the user. You also could delete the cache on log out, but what you can't do is delete the cache when the browser or tab closes, because then you don't have a cache at all. And more than likely most devs wont even think on this and just imagine that their cache will expire at some point.<p>Gmail solves this problem by requiring a per browser opt-in via, on Chrome at least, a browser extension for client side caching.<p>I haven't investigated to see if there's some way to use the HTML5 cache.appcache window.applicationCache to solve this problem. That actually has an expire.
Cache management is hard to get right. Make sure the data you send is cacheable and let the browser manage it.<p>Browsers have complex mechanisms in place to deal with broken firewalls, high-latency links, non-conformant servers and proxy. Any client-side caching implementation is going to be slower and less complete than its browser counterpart.
What does this library offer over just using localStorage without a library? The browser API is already really easy, and with no fallbacks for IE<9 i don't really see any advantage in using this...
Amplify.js has a caching store that supports localStorage and more, abstracting away the actual storage mechanism..<p><a href="http://amplifyjs.com/api/store/" rel="nofollow">http://amplifyjs.com/api/store/</a>
Nice! Also relevant: localStorage wrapper for all browsers without using cookies or flash. <a href="https://github.com/marcuswestin/store.js" rel="nofollow">https://github.com/marcuswestin/store.js</a><p>Perhaps worth using under the hood for locache?
Why doesn't this use the userData for IE 6/7? Given that those browsers are the least performant, wouldn't it make sense to ensure caching works on them?
I find the batch operations odd odd:<p>1. why have a different method for multiple values rather then check parameter type for the normal methods (e.g. if 'set' received an object or get received an array).<p>2. getMany returns an array instead of an object mapping key to value. Sure may be more efficient but less convenient to use.