In this recipe, we look at how we can cache a set of critical resources to enable users to go offline and provide the user with the same experience. In the meantime, we will notify the user that they can go offline and continue to use the same features.
To get started with service workers, you will need to have the service worker experiment feature turned on in your browser settings. If you have not done this yet, refer to the first recipe of Chapter 1, Learning Service Worker Basics: Setting up service workers. Service workers only run across HTTPS. To find out how to set up a development environment to support this feature, refer to the following recipes of Chapter 1, Learning Service Worker Basics: Setting up GitHub pages for SSL, Setting up SSL for Windows, and Setting up SSL for Mac.
Follow these instructions to set up your file structure. Alternatively, you can download the files from the following location: