The most important service worker superpower is the ability to use a local response cache, making the network optional. Service workers can do this because they can intercept network requests and check if a response has previously been cached before passing the request to the network. They can also be programmed to cache any network response for future use. This allows the website to possibly load instantly and regardless of the network state, which is another way of saying your web apps can work offline.
This super power relies on two newer platform features, Fetch and the Cache APIs. Before adding caching to the Podstr application, we need to learn the details of the APIs.
You first saw fetch in Chapter 4, Service Workers – Notification, Synchronization, and Our Podcast App, but it was only a simple...