Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 LocalStorage size

Can anyone explain me the size of window.localStorage (for example, 5MB in Firefox) is 5MB for each scope or only for all?

like image 970
balkon_smoke Avatar asked Aug 17 '10 08:08

balkon_smoke


People also ask

Is there any limit for localStorage?

It is limited to about 5MB and can contain only strings. Because it is tab specific, it is not accessible from web workers or service workers. LocalStorage should be avoided because it is synchronous and will block the main thread. It is limited to about 5MB and can contain only strings.

Does HTML5 support local storage?

With web storage, web applications can store data locally within the user's browser. Before HTML5, application data had to be stored in cookies, included in every server request. Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance.

What is HTML5 local storage?

Local storage is part of the HTML5 Web Storage API and it allows you to store data in the browser. Unlike cookies, data stored using local storage isn't sent back to the server. All data stays on the client, and you can currently store from 2MB to 10MB.

What is the capacity for HTML key value storage mechanism localStorage?

Local storage size capacity is approximately 10mb per domain in mobile and web browsers. The size differs in desktop browsers -- 10mb to 5mb depending on the browser version.


1 Answers

Regarding Firefox, quoting fron a John Resig article (posted January 2007)::

Storage Space

It is implied that, with DOM Storage, you have considerably more storage space than the typical user agent limitations imposed upon Cookies. However, the amount that is provided is not defined in the specification, nor is it meaningfully broadcast by the user agent.

If you look at the Mozilla source code we can see that 5120KB is the default storage size for an entire domain. This gives you considerably more space to work with than a typical 2KB cookie.

I guess it's the same for all the other browsers, but the default size can vary. For example, in Internet Explorer 8, the default is around 10Mb. Quoting from the MSDN article on DOM Storage:

window.localStorage

The localStorage attribute provides persistent storage areas for domains. It allows Web applications to store nearly 10 MB of user data, such as entire documents or a user's mailbox, on the client for performance reasons.

like image 111
Daniel Vassallo Avatar answered Nov 14 '22 14:11

Daniel Vassallo