This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes HTML5 Local Storage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML5 Local Storage" Watch "HTML5 Local Storage" New topic
Author

HTML5 Local Storage

Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Hi Rob,

Html 5 look really promising and have a lot of cool features for developers, reading a bit about it I came across the Local Storage, I read that is is a much better way to store data than Cookies. I have a couple of questions about it, there they go:

How does the Storage store the information? I mean, is it a physical file in the system like Cookies were?
What does it make it better than Cookies?
Is it possible to delete this data? This question goes in both directions as developer and user, I mean, is it possible to programatically delete the data and as a user can I delete local data as I am able with individual cookies?

Thanks for coming here to help us out

Cheers
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

The main advantage local storage has over cookies is that the data doesn't get sent along with each HTTP request and response, saving you many bytes in network load and improving performance. How local storage is implemented depends on the browser, Firefox sticks them all into a SQLite database as far as I'm aware. As a user, a browser should provide an interface to clear stored data for any particular site. As a developer, there's a removeItem method.


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 169
Hi Rob,

I saw this response about local data in HTML5 and was kind of surprised at how it works.


Firefox sticks them all into a SQLite database as far as I'm aware.


This seems quite alarming in terms of performance .
Is is really quicker for a browser to open a database and run a query to access site specific data than to set and read a cookie ?

Thanks,
Paul
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

I doubt it, Firefox stores nearly everything in SQLite databases, including cookies I think. If filesytems were faster than databases, what would be the point of databases?

At this point I should make sure you're aware: I'm not an expert in writing browsers, or even filesystems vs databases, so someone could come along and point out I'm wrong any minute, but this is the impression I got from different defects I glanced through in Bugzilla over recent years. Mozilla have been pushing a lot of their stuff into SQLite instead of using custom storage solutions.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Seems like an assumption without any basis in fact. Is there any evidence to support performance concerns with the use of SQLLite by Firefox?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 169
I don't know how Firefox uses SqlLite . If it automatically opens up a database every time it starts, then writing to a database that is already in memory would be quicker than disk I/O.
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

Now that I'm no longer replying on my phone, here's a ls *.sqlite of my Firefox profile:



Cookies are there on line 5, local storage data is in webappsstore.sqlite.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Thanks Rob for the replies and the others for adding info-discussion.

Cheers.
 
 
subject: HTML5 Local Storage
 
Similar Threads
https and session state
Cookies vs HttpSession values?
Java Preferences
Changing Registry setting at client end Using JSP ????
Problems deleting a cookie....