In the second recipe of this chapter, Implementing read-through caching, we discussed caching all resources at the time of the first request, and we talked about how it does not suit some scenarios, such as news or sports, where most articles will become outdated and you will never access them again. The solution we pointed out at the time was selective caching. So let's look at a working example.
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: Setting up GitHub pages for SSL, Setting up SSL for Windows, and Setting up SSL for Mac.