HTML5 & Web APIs (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Client-Side Storage: `localStorage` vs `sessionStorage` vs `IndexedDB` vs Cookies.
senior LevelMost AskedCLISystem Design
In Simple Words:
- Cookies: ~4KB capacity. Sent with every HTTP request; supports
HttpOnlyandSameSiteflags for secure authentication session tokens. localStorage: ~5-10MB capacity per origin. Persistent until manually cleared. Synchronous API (can block main thread).sessionStorage: ~5MB capacity. Cleared when browser tab/window is closed.IndexedDB: Hundreds of megabytes / gigabytes. Asynchronous, transactional, NoSQL object database supporting indexing and binary blobs. Ideal for offline PWAs.