Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a limit to the key length for localStorage?

Is there any limit (up to the amount of local storage available) for the key when using localStorage?

i.e. can I do something like:

localStorage.setItem("pretend that this is a 1MB string", "whatever");  
like image 461
chris Avatar asked Dec 01 '11 17:12

chris


People also ask

Is there any limit for LocalStorage?

It is limited to about 5MB and can contain only strings. LocalStorage is not accessible from web workers or service workers. Cookies have their uses, but should not be used for storage.

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.

What is key in LocalStorage?

The key() method returns name of the key with the specified index. The key() method belongs to the Storage Object, which can be either a localStorage object or a sessionStorrage object.

What is the limit of data size LocalStorage 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.


1 Answers

Yes, the limit is 5MB per domain. Your string can be as long as you want. The total usage must, however, be under 5 MB.

http://dev.w3.org/html5/webstorage/

http://www.stackoverflow.com/questions/2747285/html5-localstorage-restrictions-and-limits

like image 74
Aniket Avatar answered Sep 22 '22 19:09

Aniket