JavaScript · Senior · Question 41 of 75
Where should you store large structured data on the client (e.g. an offline cache)?
- ✓Correct answer: In IndexedDB - an async database with indexes and a large quota
- 2In
localStorage- it's synchronous and stores objects directly - 3In cookies - they sync with the server automatically
Explanation
localStorage is limited to a few megabytes, stores only strings and blocks the thread. Cookies are small (~4 KB) and are sent with every request. IndexedDB stores objects and Blobs and supports transactions and indexes; it's easier to use via wrappers like idb.