All Projects β†’ addyosmani β†’ storage-on-the-web

addyosmani / storage-on-the-web

Licence: other
πŸ—ƒ Comparing storage options for the open web in 2016

What should you use for offline storage of your Progressive Web App?

Recommentations:

  • URL addressable resources: Use the (Service Worker) Cache API
  • All other data: IndexedDB (using a Promise wrapper library)
Type Sync Async Web Workers Window Service Workers Notes Libraries
IndexedDB βœ” (event based) βœ” βœ” βœ” Nearly unlimited storage. Mandatory complexity (schema versioning, transactions). Security (per-origin). localForage (promises, legacy browser support), idb-keyval (<500 bytes, promises, if only need key-value), idb (promises, also does iteration, indexing), Dexie (complex queries, secondary indices), PouchDB (sync), Lovefield (relational), ydn-db (dexie-like, works with WebSQL)
Cache API βœ” (promise based) βœ” βœ” βœ” sw-toolbox
Cookies βœ” Size-limited, only strings. js-cookie, Cookies.js
Web Storage βœ” Size-limited, only strings. store.js, lawnchair
File API βœ” (callback based) βœ” βœ” βœ” Superseded by the File and Directory Entries API FileAPI library. For file-saving see FileSaver.js and the writable-files proposals
WebSQL βœ” (callback based) Nearly unlimited storage. Not available in a Web/Service Worker. Rejected by Edge, Firefox. Likely to unship in Chrome.
AppCache βœ” Chrome: Deprecating HTTP support, Firefox: Intent to Deprecate
FileSystem βœ” βœ” (callback based) βœ” βœ” Nearly unlimited storage. Sandboxed - not native file access. No interest outside Chrome
  • "Nearly unlimted storage" generally means storage up until the available quota is reached
  • If the SW cache (Cache API) is full, the browser will fail to cache more data (this applies to all origin storage, including IDB). Date headers can be used to get the age of cached items for cache invalidation.

Current and future work

Resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].