HTML5本地存储与会话存储 [英] HTML5 Local storage vs. Session storage
问题描述
除了非持久性和仅限于当前窗口的范围之外,对本地存储的会话存储有任何好处(性能,数据访问等)吗?
localStorage
和 sessionStorage
均扩展 code>。除了
sessionStorage
的预期非持久性之外,它们之间没有区别。
也就是说,存储在 localStorage
中的数据会一直存在,直到被明确删除。所做的更改已保存,可用于当前和将来对网站的所有访问。
对于 sessionStorage
,仅进行更改每个窗口都可用(或Chrome和Firefox等浏览器中的标签)。所做的更改已保存并可用于当前页面,以及将来访问在同一窗口上的网站。窗口关闭后,存储将被删除。
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?
localStorage
and sessionStorage
both extend Storage
. There is no difference between them except for the intended "non-persistence" of sessionStorage
.
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.
For sessionStorage
, changes are only available per window (or tab in browsers like Chrome and Firefox). Changes made are saved and available for the current page, as well as future visits to the site on the same window. Once the window is closed, the storage is deleted.
这篇关于HTML5本地存储与会话存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!