Persistent Data Storage API
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.




Better Than Floating - New Number Format Avoids Imprecision

It is well known that the way computers do arithmetic isn't the same way we do arithmetic, but if you thought that IEEE 754 floating point was the last word then you need to rethink. A new format [ ... ]

Mozilla Looking For a New Home For Thunderbird

The writing has been on the wall for Mozilla Thunderbird for quite some time. Now Mozilla is actively engaged in the process of getting rid of it. Could Thunderbird spread its wings and have a new lea [ ... ]

More News

Last Updated ( Thursday, 01 August 2013 )

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