HTML5 LocalStorage size

那年仲夏 提交于 2019-12-07 03:40:00

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/3500713/html5-localstorage-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!