This document compares and contrasts Application Cache and Local Storage. Application Cache allows web applications to work offline by caching app assets defined in a cache manifest file. Local Storage stores key-value pairs locally and can be retrieved later, but operates synchronously and has a smaller storage limit than Application Cache. The document provides tips for using Application Cache such as listening for updates and using versioning in the manifest file. It recommends an approach of storing backend data in Local Storage and templates in Application Cache to build an offline-first application.
Convert to study guideBETA
Transform any presentation into a summarized study guide, highlighting the most important points and key insights.
7. Local Storage
A storage mechanism through which string
key/value pairs can be securely stored and
later retrieved for use.
8. // Setting data
localStorage.setItem(userDetails, JSON.stringify(dataObj));
// Retrieving the same data
var userDetails = JSON.parse(localStorage.getItem(userDetails));
* There is also a sessionStorage API