Imagine you run an application that polls an API every 5 seconds, but for some reason the service goes down, and you keep polling and getting timeouts. You would need to handle the error quickly and gracefully. The circuit breaker pattern detects failures and prevents your application from performing actions that are doomed to fail.
In this recipe, we will look at how to implement a circuit breaker library with the service worker.
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...