In this recipe, we are going to look at how we can use the service worker as a load balancer so we can decide which content provider is the best suited for us to get content from, depending on the load of the content provider.
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. You also need to make sure Node.js is available to you. You can read how to install Node.js at https://nodejs.org/en/.