Persistent Data Storage API
Written by Kay Ewbank   
Thursday, 01 August 2013

W3C’s web applications working group has published its recommendation for Web Storage. The spec defines an API for persistent data storage of key-value pair data in web clients.

The spec is based around two related mechanisms, similar to HTTP session cookies, for storing structured data on the client side.

One example of how data could be handled better in web clients is where a user is carrying out similar transactions in multiple windows at the same time.  For example, a user could be buying plane tickets in two different windows, both using the same site. It’s the sort of thing many of us do; open two windows, try different combinations of dates and times, perhaps different destinations to see how that affects the overall cost, before finally completing the purchase in just one window.

The W3C specification points out that cookies don't really handle this case well. If the site used cookies to keep track of which ticket the user was buying, then as they click from page to page in both windows, the ticket currently being purchased will "leak" from one window to the other, potentially causing the user to buy two tickets for the same flight without really noticing.

To get around this problem, the new specification introduces the sessionStorage IDL attribute. Sites can add data to the session storage, and it will be accessible to any page from the same site opened in that window.

For example, a page could have a checkbox that the user ticks to indicate that he wants insurance. A later page could then check, from script, whether the user had checked the checkbox or not. Importantly, if the user had multiple windows opened on the site, each one would have its own individual copy of the session storage object.

The second idea in the specification in that of storage that spans multiple windows, and lasts beyond the current session.  This is aimed at web apps that want to store megabytes of user data on the client side for performance reasons. Examples given are documents written by the user, or a user's mailbox. Because a cookie is transmitted with every request, the large quantity of data would be transmitted if the app used a cookie. The new spec is for a localStorage IDL attribute that can be used to access a page's local storage area, so making it possible to store data locally to a page, and have that data accessible to the web. Each site would have its own separate storage area.

The new specification also include details of how sites should handle security for the local storage.

 

W3Clogo

More Information

Web Storage Recommendation

Related Articles

Web Telephony API

Draft Specification of Streams API

Web Alarms API

Web Crypto APIs Work In Progress

W3C Draft For Device-Independent Input

W3C Publishes Push API Draft Specification

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin,  or sign up for our weekly newsletter.

 

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

 

Banner


GR00T Could Be The Robot You Have Always Wanted
27/03/2024

We may not have flying cars, but we could well soon have robots that match up to predictions for the 21st century. Nvidia has announced GR00T, a cleverly named project to build robots using foundation [ ... ]



The Appeal of Google Summer of Code
21/03/2024

With the list of participating organizations now published, it is time for would-be contributors to select among them and apply for Google Summer of Code (GSoC). Rust has joined in the program fo [ ... ]


More News

Last Updated ( Thursday, 01 August 2013 )