Search⌘ K

The Cache-Only Strategy

Explore the cache-only strategy used in Progressive Web Applications to serve static content from the cache regardless of network availability. Learn how to cache the app shell during service worker installation and handle fetch events to ensure fast and reliable access to core assets. This lesson guides you through implementing and testing this strategy for enhanced PWA performance.

How it works

This strategy uses a service worker that listens to page requests via the fetch event and responds to those requests from the cache.

Perform the following steps to implement the following strategy:

  • Cache the static content (e.g., app shell) during the service worker’s install event.
  • Handle the page requests in the service worker’s fetch event.
  • Serve it from the cache even if the network is available—if the requested asset is from the app shell.

The slides given below illustrate the steps of this strategy:

Use case

...