2024-04-03 08:20:17 +00:00
|
|
|
# Storage
|
|
|
|
|
|
|
|
## Local Storage
|
|
|
|
|
|
|
|
Data in the local storage is persisted even after the user closes the tab (or
|
|
|
|
the browser itself). This is in contrast with session storage, where the data is
|
|
|
|
cleared when the browser tab is closed.
|
|
|
|
|
|
|
|
The data in local storage is tied to the Document's origin (scheme + host).
|
|
|
|
|
2024-04-13 02:00:32 +00:00
|
|
|
Some things that get stored here are:
|
|
|
|
|
|
|
|
* Details about the logged in user, in particular their user id and a auth token
|
|
|
|
we can use to make API calls on their behalf.
|
|
|
|
|
|
|
|
* Various user preferences
|
|
|
|
|
2024-04-03 08:20:17 +00:00
|
|
|
## Session Storage
|
|
|
|
|
2024-04-13 02:00:32 +00:00
|
|
|
Data tied to the browser tab's lifetime.
|
|
|
|
|
|
|
|
We store the user's encryption key here.
|
|
|
|
|
2024-04-03 08:20:17 +00:00
|
|
|
## Indexed DB
|
|
|
|
|
|
|
|
We use the LocalForage library for storing things in Indexed DB. This library
|
|
|
|
falls back to localStorage in case Indexed DB storage is not available.
|
2024-04-13 02:00:32 +00:00
|
|
|
|
|
|
|
Indexed DB allows for larger sizes than local/session storage, and is generally
|
|
|
|
meant for larger, tabular data.
|
|
|
|
|
|
|
|
## OPFS
|
|
|
|
|
|
|
|
OPFS is used for caching entire files when we're running under Electron (the Web
|
|
|
|
Cache API is used in the browser).
|
|
|
|
|
|
|
|
As it name suggests, it is an entire filesystem, private for us ("origin"). In
|
|
|
|
is not undbounded though, and the storage is not guaranteed to be persistent (at
|
|
|
|
least with the APIs we use), hence the cache designation.
|