Use Local storage to make your web applications rock

added by vijayst
10/9/2011 9:55:04 AM

299 Views

Single page web applications are on the rise that use sophisticated HTML5, Javascript, CSS3. Local Storage is useful for these applications to store application specific data upto 5 MB. This post describes how to use Local storage in your applications.


2 comments

dpeterson
10/10/2011 9:27:48 AM
At the office I've been using local storage to cache the JSON returned from AJAX requests. This includes search results as well as lazily-loaded page content. As the web application using this strategy relies on static data rather than dynamic content, my caching strategy revolves around a simple database-date cookie which is set server side in a config file. Whenever the database is updated with fresh data, that config file is updated and client side caches in local storage are invalidated and cleared out.

The biggest problem I have run into with local storage is that no API exists for determining how much space you have currently, or more importantly how much you have left available. The current generation of browsers are also inconsistent in how they handle running out of local storage space: It's not easy recover when you attempt to put something into local storage that will exceed its capacity.

bradygaster
10/10/2011 11:58:08 AM
This is great! I wish I'd had something like this in HTML or even a different mobile client technology a few years back when I was working on mobile apps that required store-and-forward methodologies to do their work and to enable the ability for our business clients to do their work in the field during times of disconnectedness. I did a sample of this using Spine.js.