Appendix B: Storage options comparison table
|
Sent with HTTP requests |
Sync/Async |
Capacity |
Scope |
Best for |
| Cookies |
Yes, automatically |
Sync (document.cookie) |
~4KB |
Configurable via Domain/Path |
Auth tokens (as HttpOnly), small server-needed flags |
localStorage |
No |
Sync |
~5-10MB |
Per-origin, persists forever |
Small persistent client-only prefs |
sessionStorage |
No |
Sync |
~5-10MB |
Per-tab, per-origin, dies with tab |
Per-tab draft/wizard state |
| IndexedDB |
No |
Async |
Large (browser-managed, often 100s of MB+) |
Per-origin, persists |
Structured/large offline data, encrypted blobs |
| Cache API |
No |
Async |
Large, shares quota with IndexedDB |
Per-origin, managed by Service Worker |
Cached network responses for offline use |
| In-memory (JS variable) |
No |
Sync |
Limited by heap |
Dies on page reload/navigation |
Secrets you deliberately want to NOT persist |
Generated from real-life-JS-guide.md · 8 Oct 2026 16:36