A ServiceWorker is a proxy that sits between our web applications and the server. It catches requests that are made and checks if there is a pattern that matches it. If a pattern matches it, then it will run the code that fits that pattern. Writing code for a ServiceWorker is a bit different than it is for SharedWorker and DedicatedWorker, which we looked at previously. Initially, we set it up in some code and it downloads itself. We have various events that tell us the stage that the worker is in. These run in the following order:
- Download: The ServiceWorker is downloading itself for the domain or subdomain.
- Install: The ServiceWorker is attaching itself to the domain or subdomain where it is hosted.
- Activate ...