The Network-With-Cache-Fallback Strategy

Understand how the network-with-cache fallback strategy combines using assets stored in the cache and making network requests.

How it works

The network-with-cache-fallback strategy, also known as the network-first strategy, is a technique for handling requests in a service worker. Implement it using the following steps:

  • Listen to requests in the service worker’s fetch event.
  • Send the request to the network.
  • Return it to the requester if the network response is received successfully.
  • Search for the request in the cache and return the response if available—if the network request fails.

The slides below illustrate the steps to implement this strategy.

Get hands-on with 1200+ tech skills courses.