views:

455

answers:

2

Hi,

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

Does anyone know if there is a definition which applies to all browsers, respectively does anyone know the limitations for Chrome5?

Thanks, in advance, for your help

+4  A: 

Quoting from the Wikipedia article on Web Storage:

Web storage can be viewed simplistically as an improvement on cookies, providing much greater storage capacity (5MB per domain in Mozilla Firefox, Google Chrome, and Opera, 10MB per storage area in Internet Explorer) and better programmatic interfaces.

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

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.)

Daniel Vassallo
A: 

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.