localStorage数据持久性 [英] localStorage data persistence

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

问题描述

我最近发现用户可以清除HTML5的 localStorage 值,这让我想知道......确切的持续时间是 localStorage ?如果Flash崩溃并擦除我的所有cookie,我会丢失localStorage数据吗?如果我的本地缓存被清除以便为浏览器更新让路怎么办?

I recently discovered that it's possible for the user to clear HTML5's localStorage value, which caused me to wonder... exactly how persistant is localStorage? If Flash crashes and wipes all my cookies, would I lose my localStorage data? What if my local cache was cleared to make way for a browser update?

我见过这个答案,但它不能解决浏览器崩溃,更新,缓存清除等问题。 localStorage 真的和真正的永久性,因为前面提到的答案似乎是保守的?

I've seen this answer, but it doesn't address browser crashes, updates, cache clearing, etc. Is localStorage really and truly permanent, as the aforementioned answer seems to mantain?

推荐答案

LocalStorage不是永久性的。存储属于用户,因此用户可以根据需要清除它。其他网络应用程序无法解决它,但用户可以自由清除或修改它,如果他们想要 - 这是他们的数据,就像属于本地安装的应用程序的文件在计算机用户的控制下。

LocalStorage is not permanent. The storage belongs to the user so the user can clear it if they want to. Other web apps cannot mess with it, but the user is free to clear it or modify it if they want - it's their data, much like files that belong to a locally installed application are under the control of the computer user.

此外,LocalStorage可以在空间不足时回收。

In addition, LocalStorage can be recycled when space is low.

您应该将LocalStorage视为通常的长期缓存将保留在该特定计算机上的特定浏览器,但并不总是在那里。任何真正持久的状态都必须存储在您自己的服务器上。

You should think of LocalStorage as a long term cache that usually will remain with that particular browser on that particular computer, but will not always be there. Any truly persistent state must be stored on your own server.

哎呀,如果用户只是决定切换到另一个浏览器(更不用说是新计算机),那么所有本地存储在新浏览器中显示为空。

Heck, if the user just decides to switch to another browser (much less a new computer), all Local Storage will appear to be empty in the new browser.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆