html 5存储websql和localStorage:数据存储多长时间?

发布于 2024-12-22 10:52:55 字数 175 浏览 1 评论 0原文

使用新的 Html 5,有 3 种主要方式在浏览器中存储数据:

  • localStorage
  • WebSQL DB
  • 索引数据库

我想知道,对于每种类型,数据存储多长时间? 如果用户第二天输入,数据还会在吗?一个月后?一年?

谢谢

With new Html 5 there are 3 main ways to store data in your browser:

  • localStorage
  • WebSQL DB
  • Indexed DB

I wanted to know, for each of the types, for how long data is stored?
If the user enters the day after, the data will still be there? after one month? and one year?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一抹微笑 2024-12-29 10:52:55

这个问题最正确的答案是:你不知道。

用户可以随时擦除他/她的本地数据,任何类型的本地存储都受用户偏好的影响,并且被认为非常不稳定。但是,根据 Web 存储规范,没有定义过期时间

存储数据过期

<块引用>

如果用户如此配置,用户代理可以在一段时间后自动删除存储的数据。

例如,用户代理可以配置为将第三方本地存储区域视为仅会话存储,一旦用户关闭了所有可以访问数据的浏览上下文,就删除数据。

这可能会限制网站跟踪用户的能力,因为该网站只能在用户通过网站本身进行身份验证时(例如通过购买或登录服务)在多个会话中跟踪用户)。

但是,这也降低了 API 作为长期存储机制的实用性。如果用户没有完全理解数据过期的影响,它还可能使用户的数据面临风险。

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

The most correct answer to this question is: You don't know.

The user could wipe his/her local data at any time, and any type of local storage is subject to user preferences and to be considered extremely volatile. However, there is no defined expiration time, according to Web Storage specifications:

Expiring stored data

User agents may, if so configured by the user, automatically delete stored data after a period of time.

For example, a user agent could be configured to treat third-party local storage areas as session-only storage, deleting the data once the user had closed all the browsing contexts that could access it.

This can restrict the ability of a site to track a user, as the site would then only be able to track the user across multiple sessions when he authenticates with the site itself (e.g. by making a purchase or logging in to a service).

However, this also reduces the usefulness of the API as a long-term storage mechanism. It can also put the user's data at risk, if the user does not fully understand the implications of data expiration.

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

我一直都在从未离去 2024-12-29 10:52:55
  • WebSQL 已弃用。请参阅此处
  • 索引数据库是持久的。
  • localStorage 也是持久的(不要与 sessionStorage 混淆)。

“持久”伴随着 atornblad 指出的警告:只有在用户决定擦除自己的数据之前它才会持久。

  • WebSQL is deprecated. See here.
  • Indexed DB is persistent.
  • localStorage is also persistent (not to be confused with sessionStorage).

'Persistent' comes with the caveat that atornblad pointed out: it's only persistent until the user decides to wipe their own data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文