同事報案,他的電腦使用某個靠 localStorage 暫存資料的網頁時,暫存資料常會無故消失,沒法放過夜。

經此一事,學到冷知識 - IE 的「結束時刪除瀏覽歷程記錄」(而且有人選擇勾選),清除範圍包含 localStorage:

依據微軟文件

However, users can clear storage areas at any time by selecting Delete Browsing History from the Tools menu in Internet Explorer, selecting the Cookies check box, and clicking OK.

可推敲出 localStorage 與 Cookie 被歸類在一起,而 IE 定義的瀏覽歷程記錄包含「暫存檔、歷程記錄、Cookie、儲存的密碼及網頁表單資訊」。而 Chrome 也類似,區分成「瀏覽記錄、Cookie 其他網站資料、快取圖片及檔案」,localStorage 也與 Cookie 被歸類在一起:

總之,記住一點就對了 - 當瀏覽器清除 Cookie 時,localStorage 也會一併被清除。

Notes about IE's 'Deleting browsing history on exit' option will clean localStorage, too.


Comments

Be the first to post a comment

Post a comment