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

Banner


Feminist Hacker Barbie?
26/11/2014

Can you see Barbie as a computer engineer? No, apparently nor can Mattel, though the online community is giving a much more accurate and amusing view of how things would work out under the hashtag #fe [ ... ]



Google Offers Cash Incentives to US Public Schools
01/12/2014

Computer Science Education Week starts next Monday. If students want to do rather more than an hour of code, Google has partnered with Codecademy to encourage teachers in US Public Schools to adopt a  [ ... ]


More News

Last Updated ( Thursday, 01 August 2013 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.