Persistence of localStorage data

I recently discovered that a user can clear the HTML5 localStorage , which made me wonder ... exactly how persistent is localStorage ? If Flash crashes and deletes all my cookies, would I lose my local storage data? What should I do if my local cache has been cleared to free up space for browser updates?

I saw this answer , but it does not account for browser crashes, updates, clearing the cache, etc. Is localStorage really and truly persistent since the above answer seems mantain?

+8
javascript html5 local-storage
source share
2 answers

LocalStorage is not permanent. The storage is owned by the user, so the user can clear it if he wants. Other web applications cannot mess with it, but the user can clean or change them if they want - this is their data, just like the files belonging to a locally installed application are under the control of the computer user.

In addition, LocalStorage can be recycled when space is low.

You should think of LocalStorage as a long-term cache that usually stays in this particular browser on that particular computer, but will not always be there. Any truly persistent state should be stored on your own server.

If the user simply decides to switch to another browser (and even more so to a new computer), all local storage will look empty in the new browser.

+8
source share

This is certainly not permanent. You should not count on it.

In addition to the situation when the user actively cleans the repository, his machine can be reinstalled. Or he can log in from another computer. Your application will be able to handle this.

+1
source share

All Articles