Open knod opened 7 years ago
It seems that not only does clearing cookies clear localStorage in some browsers (http://sharonminsuk.com/blog/2011/03/21/clearing-cache-has-no-effect-on-html5-localstorage-or-sessionstorage/, check the comments), some other app can also clear everything out of localStorage: http://stackoverflow.com/a/7667973/3791179 (It seems clearing cache doesn't clear localStorage.)
Another option would be IndexedDB, where data can only be cleared if the database name is invoked. It's possible that other origins can't clear the database, even if they know the name. It's possible that other origins can't access the database either, though. More research needs to be done into that.
If IndexedDB is the way we're going, a possible useful library for this would be localForage, though it uses localStorage as a backup to IndexedDB, which might create inconsistency. The documentation for setting the database name is here: https://localforage.github.io/localForage/#settings-api-config.
In the future, service workers and (foreign fetch)[https://developers.google.com/web/updates/2016/09/foreign-fetch] may be useful.
Possible instructions for getting a bookmarklet on Chrome for mobile (don't know how old it is): https://www.cnet.com/how-to/how-to-use-bookmarklets-in-mobile-chrome/
Of course, performance on mobile will have to be tested and fallbacks will have to be provided if the current setup is too slow for slower systems.
Basically, the current plan for robustness is this: Provide an extension where available. Provide a bookmarklet if needed as a fallback using IndexedDB if possible, localStorage if not, with a check in the bookmarklet that makes sure the data is there. If the data is not and there's an internet connection, re-cache the code. Also, provide fallbacks for slow systems (method of detection needed).
Bookmarklets can only be a certain size, and we definitely exceed that. An option is to store most of the code on local storage through some prompt on the site, and then use the bookmarklet as the trigger to start that code going. We'll see how reasonable that is.
For example, ~I'm told that when the user clears their cache, it also clears local storage~ (though this implies otherwise: http://superuser.com/a/236600). Clearing cookies might also do it.