ente/web/docs/storage.md

40 lines
1.2 KiB
Markdown
Raw Normal View History

# 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:
2024-04-13 07:47:42 +00:00
- 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.
2024-04-13 02:00:32 +00:00
2024-04-13 07:47:42 +00:00
- Various user preferences
2024-04-13 02:00:32 +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.
## 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).
2024-04-30 04:53:33 +00:00
As it name suggests, it is an entire file system, private for us ("origin"). In
2024-04-13 02:00:32 +00:00
is not undbounded though, and the storage is not guaranteed to be persistent (at
least with the APIs we use), hence the cache designation.