HTML5 localStorage size limit for subdomains
HTML5's localStorage databases are usually size-limited — standard sizes are 5 or 10 MB per domain. Can these limits be circumvented by subdomains (e.g. example.com, hack1.example.com and hack2.example.com all have their own 5 MB databases)? And is there anything in the standard that specifies whether parent domains can access their children's databases? I can't find anything, and I can see arguments for doing it either way, but it seems like there has to be some standard model.
Solution 1:
From http://dev.w3.org/html5/webstorage/#disk-space
A mostly arbitrary limit of five megabytes per origin is recommended. Implementation feedback is welcome and will be used to update this suggestion in the future.
It also mentions that :
User agents should guard against sites storing data under the origins other affiliated sites, e.g. storing up to the limit in a1.example.com, a2.example.com, a3.example.com, etc, circumventing the main example.com storage limit.
Solution 2:
Here's a pretty detailed test result with plenty of desktop and mobile browsers covered: http://dev-test.nemikor.com/web-storage/support-test/
Which confirms this bug report: http://code.google.com/p/chromium/issues/detail?id=58985#c15
You can rely on only 2.5MB, not 5MB, based on the string length that you can store.
Solution 3:
I missed this question when I asked "Is 5MB the de facto limit for W3C Web Storage?", but I got basically the same answer. If you want more information, I did link to some browser specific limits in my question.
Solution 4:
A better solution is to use the [HTML5 IndexedDB for offline storage.]1
It looks like the replacement for the old Web SQL (which seems to be misnamed b/c it's for offline storage) is: Indexed DB, which allows offline storage and is still supportd:
IndexedDB is new in HTML5. Web Databases are hosted and persisted inside a user's browser. By allowing developers to create applications with rich query abilities it is envisioned that a new breed of web applications will emerge that have the ability to work online and off-line.
More info and a test-app at: http://ido-green.appspot.com/WebSQL-IndexedDB-example/jqm_indexedDB.html