HTML5 本地存储与会话存储 [英] HTML5 Local storage vs. Session storage

查看:29
本文介绍了HTML5 本地存储与会话存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了非持久性和仅限于当前窗口之外,会话存储相对于本地存储还有什么好处(性能、数据访问等)?

Apart from being non persistent and scoped only to the current window, are there any benefits (performance, data access, etc) to Session Storage over Local Storage?

推荐答案

localStoragesessionStorage 都扩展存储.除了 sessionStorage 的预期非持久性"之外,它们之间没有区别.

localStorage and sessionStorage both extend Storage. There is no difference between them except for the intended "non-persistence" of sessionStorage.

也就是说,存储在localStorage中的数据一直存在,直到被明确删除.所做的更改将被保存并可供所有当前和将来访问该网站的人使用.

That is, the data stored in localStorage persists until explicitly deleted. Changes made are saved and available for all current and future visits to the site.

对于sessionStorage更改仅适用于每个标签.所做的更改将被保存并可用于在该标签中的当前页面,直到它被关闭.一旦关闭,存储的数据将被删除.

For sessionStorage, changes are only available per tab. Changes made are saved and available for the current page in that tab until it is closed. Once it is closed, the stored data is deleted.

这篇关于HTML5 本地存储与会话存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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