Nine ways to accelerate HTML5 applications-------3. Using HTML5 Web Storage
When you need to store some data on your browser, you may first consider cookies, which are included with each browser request. The more efficient way to HTML5 is to store--web Storage locally.
There are two Web Storage objects: Sessionstorage and Localstorage, the stored data is not transmitted over HTTP requests, so there is no effect on the requested time parameter, and here is a short sample code:
Check to see if Localstorage is present (browser supports HTML5)
if ((' Localstorage ' in window) && window.localstorage!== null) {
Store items
localstorage.wishlist = ' [' Bear ', ' Cow ', ' Pig '] ';
}
As we can see from the code above, it is simpler to use cookies than to specify the expiration time.
Nine ways to accelerate HTML5 applications-------3. Using HTML5 Web Storage