Thursday, June 6, 2024
 Popular · Latest · Hot · Upcoming
184
rated 0 times [  185] [ 1]  / answers: 1 / hits: 22524  / 11 Years ago, sat, june 22, 2013, 12:00:00

I want to use localStorage to store large amount of data(like 800GB), according to http://arty.name/localstorage.html and also I'm using Firefox, I changed my localStorage size and also the cache size. So the size isn't a problem. However, I write some jquery like the following:



 $(a[href]).each(function(){
$(this).click(function(event){
localStorage.test += somenewinformation;
...


If this localStorage.test already have large amount of data like 400GB, so the storing information step would be extremely slow. When I click on a link,will the jquery wait for me to finish the appending new information to localStorage.test or it will just go to the next page and information in localStorage.test will all lost or localStorage.test will just remain the old value? What I dont understand is whether a new thread will be generated to do this storing in background or not and closing browser in the middle will affect it or not.



Sorry about the messy description and thanks in advance!


More From » jquery

 Answers
7

You can't! The usual limit is 5 MB.


Some browsers such as Opera allow you to adjust the size, but this is purely dependent on the browser and is a user-initiated action, not a programmable one.


And even if you could remember that localStorage can only store strings, so anything else need to be stringified first. That together with this being an key-value storage array you will run into pretty poor performance at the end.


If you need large storage capacity, look into File API instead. This is made to work with large files (Blobs) and you can store anything as a Blob.


800 Gb is a large size and File API can only work as fast as the file system (at best, more likely a bit slower as it is sandboxed, ie. not a pure file system).


More about File System API (Note: discontinued as of 4/2014):

http://www.w3.org/TR/file-system-api/


Tutorial:

http://www.html5rocks.com/en/tutorials/file/dndfiles/


Blob:

https://developer.mozilla.org/en-US/docs/Web/API/Blob


Update As the Filesystem API has been discontinued there are essentially only two options left (besides from storing data to the server):



  • Indexed Database API aka Indexed DB (recommended)

  • Web SQL (deprecated but still supported in browsers such as Safari)


Also these are initially limited in size by the browser. It is possible to request a larger quote which the user is asked to accept.


See more details about this API here:

http://www.w3.org/TR/IndexedDB/


[#77470] Friday, June 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aileenreynap

Total Points: 140
Total Questions: 106
Total Answers: 99

Location: Andorra
Member since Sun, Oct 18, 2020
4 Years ago
;