Reference · print-friendly
One page for design reviews. Walk top to bottom; stop when a row rejects the current candidate.
| If… | Prefer… |
|---|---|
| Re-fetch is cheap; no session continuity | Memory only |
| Small string/JSON; this tab only; die on close OK; isolation is a feature | sessionStorage |
| Tiny string; survive restart; share all tabs | localStorage (sparingly) |
| Auth cookies / must travel with HTTP | Cookies (careful) — not Web Storage as a vault |
| Durable structured app data | IndexedDB |
| HTTP assets / app shell | Cache Storage (+ SW) |
| File-shaped bytes | OPFS |
| Multi-tab live sync of one key |
BroadcastChannel / localStorage
events / server — not sessionStorage
|
getItem / setItem / removeItem / clearJSON.stringify / parse; null-guard missing keysstorage events: other documents only; session does
not cross tabs
window.open: initial copy of opener’s session map, then
diverges — not a live channel
storageAvailable); catch write errorsQuotaExceededError / disabled storage (cookie policy)“We use sessionStorage | localStorage | memory | IDB | … because job + lifetime; shape is methods + JSON; isolation is tab-only / cross-tab; we own probe · quota · no secrets · no multi-tab bus.”