除了非持久化和仅作用于当前窗口之外,会话存储相对于本地存储是否有任何好处(性能,数据访问等)?


当前回答

性能方面,我的(粗略的)测量在1000次写入和读取时没有发现差异

安全方面,从直觉上看,localStore可能会在sessionStore之前关闭,但没有具体的证据-也许其他人会?

功能方面,与digitalFresh一致

其他回答

在我看来,会话存储相对于本地存储的优势在于,它在Firefox中具有无限的容量,并且不会持续比会话更长的时间。(当然这取决于你的目标是什么。)

sessionStorage与localStorage相同,只是它只存储一个会话的数据,并且当用户关闭创建它的浏览器窗口时,它将被删除。

会话存储和本地存储在行为上是相同的,除了一个是本地存储将存储数据,直到用户删除缓存和cookie,会话存储数据将保留在系统中,直到我们关闭会话i,直到我们关闭会话存储创建的窗口。

The only difference is that localStorage has a different expiration time, sessionStorage will only be accessible while and by the window that created it is open. localStorage lasts until you delete it or the user deletes it. Lets say that you wanted to save a login username and password you would want to use sessionStorageover localStorage for security reasons (ie. another person accessing their account at a later time). But if you wanted to save a user's settings on their machine you would probably want localStorage. All in all:

localStorage—用于长期使用。 sessionStorage—当您需要存储更改的东西或临时的东西时使用

性能方面,我的(粗略的)测量在1000次写入和读取时没有发现差异

安全方面,从直觉上看,localStore可能会在sessionStore之前关闭,但没有具体的证据-也许其他人会?

功能方面,与digitalFresh一致