Chapter 5. Service Worker Strategies

You’ve made some great performance enhancements to your website. Using the combined power of the Cache API and the Fetch API, you’re making your site nice and zippy.

If you recall, here’s the logic of your fetch events:

  1. When the browser requests a file,
    1. look for a matching file that has been cached;
    2. if there’s no match, fetch the file from the network.

      You can go further. You can add another step:

    3. If the file can’t be fetched, show a fallback instead.

There are a few reasons why a file couldn’t be fetched. Perhaps your server has been taken down for maintenance, or perhaps the user has lost their internet connection. The end result is the same—the ...

Get Going Offline now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.