Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the max size of localStorage values?

Since localStorage (currently) only supports strings as values, and in order to do that the objects need to be stringified (stored as JSON-string) before they can be stored, is there a defined limitation regarding the length of the values.

Does anyone know if there is a definition which applies to all browsers?

like image 444
Codekie Avatar asked Jun 07 '10 12:06

Codekie


People also ask

What is the limit of data size LocalStorage in Google Chrome?

Apps that were designed to run in Google Chrome. Note: Web storage APIs like LocalStorage and SessionStorage remain fixed at 5 MB. Note: Web storage APIs like LocalStorage and SessionStorage remain fixed at 5 MB.

Can LocalStorage be full?

In answer to your question, desktop browsers tend to have an initial maximum localStorage quota of 5MB per domain. This can be adjusted by the user in some cases: Opera: opera:config -> Domain Quota For localStorage.

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.


2 Answers

Quoting from the Wikipedia article on Web Storage:

Web storage can be viewed simplistically as an improvement on cookies, providing much greater storage capacity (10 MB per origin in Google Chrome(https://plus.google.com/u/0/+FrancoisBeaufort/posts/S5Q9HqDB8bh), Mozilla Firefox, and Opera; 10 MB per storage area in Internet Explorer) and better programmatic interfaces.

And also quoting from 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.

However, the size of this storage area can be customized by the user (so a 5MB storage area is not guaranteed, nor is it implied) and the user agent (Opera, for example, may only provide 3MB - but only time will tell.)

like image 161
Daniel Vassallo Avatar answered Oct 20 '22 00:10

Daniel Vassallo


Actually Opera doesn't have 5MB limit. It offers to increase limit as applications requires more. User can even choose "Unlimited storage" for a domain.

You can easily test localStorage limits/quota yourself.

like image 24
Tom Adler Avatar answered Oct 20 '22 01:10

Tom Adler