Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.(由于localStorage (当前)仅支持将字符串作为值,并且为了做到这一点,需要先将对象进行字符串化(存储为JSON-string),然后才可以定义值的长度限制。)

Does anyone know if there is a definition which applies to all browsers?(有谁知道是否存在适用于所有浏览器的定义?)

  ask by Codekie translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
376 views
Welcome To Ask or Share your Answers For Others

1 Answer

Quoting from the Wikipedia article on Web Storage :(引用有关Web存储Wikipedia文章 :)

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.(可以简单地将网络存储视为Cookie的一种改进,它提供了更大的存储容量( Google Chrome中每个原始站点10 MB( https://plus.google.com/u/0/+FrancoisBeaufort/posts/S5Q9HqDB8bh ),Mozilla Firefox和Opera;在Internet Explorer中每个存储区10 MB )和更好的编程接口。)

And also quoting from a John Resig article [posted January 2007]:(并且引用了John Resig的文章 [发布于2007年1月]:)

Storage Space(储存空间)

It is implied that, with DOM Storage, you have considerably more storage space than the typical user agent limitations imposed upon Cookies.(这暗示着,使用DOM存储,您具有的存储空间比对Cookie施加的典型用户代理限制要大得多。)

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.(如果您查看Mozilla源代码,我们可以看到5120KB是整个域的默认存储大小。)

This gives you considerably more space to work with than a typical 2KB cookie.(与典型的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.)(但是,该存储区的大小可以由用户自定义 (因此,不能保证5MB的存储区,也没有暗示),并且用户代理(例如,Opera只能提供3MB的存储空间,但是只有时间能说明问题)。 ))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...