localStorage 在 iPad 上可靠吗?
我看到一些人的评论表明 iPad 上的 localStorage 不可靠。谁能确认他们在 iPad 上愉快地使用 localStorage 吗?我知道也有 5Mb 的限制 - 情况仍然如此吗?
谢谢
I'm seeing a few comments from people suggesting that localStorage on an iPad is unreliable. Can anyone confirm that they are happily using localStorage on an iPad? I understand that there is a 5Mb limit too - is that still the case?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在开发一个在 iPad 上使用 localStorage 的项目。根据我的经验,localStorage 非常稳定。但是,有两件事需要考虑:
是的,存储限制仍然是 5Mb。由于字符存储为UTF16,localStorage 中只能存储2.5M 个字符。
与其他 localStorage 实现相比,localStorage.setItem() 在存储新项目之前不会删除任何具有相同键的先前项目。换句话说:当覆盖一个项目时,应该始终在调用 localStorage.setItem() 之前调用 localStorage.removeItem(),否则很快就会耗尽空间。
I've been working on a project that uses localStorage on an iPad. In my experience, the localStorage is perfectly stable. However, there are two things to consider:
Yes, the storage-limit is still 5Mb. Since characters are stored UTF16, only 2.5M characters can be stored in localStorage.
In contrast to other localStorage implementations, localStorage.setItem() doesn't delete any previous items with the same key before storing the new item. In other words: When overwriting an item, one should always call localStorage.removeItem() before calling localStorage.setItem(), or you'll quickly run out of space.