javascript – html 5 storage websql和localStorage:存储数据的时间长短?

前端之家收集整理的这篇文章主要介绍了javascript – html 5 storage websql和localStorage:存储数据的时间长短?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用新的 Html 5有3种主要方式可以在浏览器中存储数据:

> localStorage
> Websql DB
>索引DB

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

谢谢

解决方法

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

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

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.

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

猜你在找的JavaScript相关文章