Service workers
A service worker is a JavaScript script that runs on a separate thread, as a background process to your application. It acts like a proxy for the network, intercepting all calls and behaving according to a programmed strategy to serve pages and data.
We can have multiple service workers as each one is responsible for their scope. The scope is defined as the directory (URL path) where the source file for the service worker is located. Thus, a service worker placed at the root of the application will handle the entire SPA/PWA.
Service workers are installed without user intervention, so they can be used even if the user does not install the PWA. They have a well-defined life cycle (see https://web.dev/service-worker-lifecycle/), triggering events for each accomplished state. To start, a service worker needs to be first registered, then it becomes activated, and eventually, we can also unregister it. Once the service worker is activated, it will not take control of...