localStorage的持久性如何

localStorage的持久性如何

本文介绍了localStorage的持久性如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在很大程度上依赖于localStorage来创建我正在编写的插件。所有用户设置都存储在其中。某些设置要求用户使用写正则表达式,如果他们的正则表达式规则在某些时候消失,他们会很难过。
所以现在我想知道localStorage是多么持久。

I'm depending heavily on localStorage for a plugin I'm writing. All the user settings are stored in it. Some settings require the user the write regex'es and they would be sad if their regex rules are gone at some point.So now I am wondering just how persistent the localStorage is.

来自:

以上看起来就像客户端上的cookie一样。即当用户清除所有浏览器数据(历史记录,cookie,缓存等)时,localStorage也将被截断。这个假设是正确的吗?

The above looks like it works just like cookies on the clientside. I.e. when the user clears all browser data (history, cookies, cache etc) the localStorage will also be truncated. Is this assumption correct?

推荐答案

Mozilla像cookie一样实现它:

Mozilla implements it like cookies:

在DOM存储中,无法为任何数据指定有效期。所有到期规则都由用户决定。对于Mozilla,大多数规则都是从与Cookie相关的过期规则继承的。因此,您可能希望大多数DOM存储数据至少持续一段有意义的时间。

In DOM Storage it is not possible to specify an expiration period for any of your data. All expiration rules are left up to the user. In the case of Mozilla, most of those rules are inherited from the Cookie-related expiration rules. Because of this you can probably expect most of your DOM Storage data to last at least for a meaningful amount of time.

Chrome将其实现为缓存:

Chrome implements it like cache:

HTML5本地存储以字符串形式保存未加密的数据浏览器缓存

HTML5 local storage saves data unencrypted in string form in the regular browser cache.

持久性

在磁盘上直到被删除用户(删除缓存)或应用

On disk until deleted by user (delete cache) or by the app






至于替换Cookie,不完全

这篇关于localStorage的持久性如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 05:10