In Chapter 1, Introduction to Progressive Web Apps, we created a basic service worker that pre-cached the 2048 game assets. In this and the following chapters, we will dive deeper into the details of a service worker.
The service worker goes through several stages in its overall life cycle. A service worker is registered. Once the script is loaded, it triggers the ‘install’ event. At this point, the service worker is not in control of the client (browser tab).
When the service worker is cleared to control client contexts, the activate event is triggered. After this, the service worker is fully active and in control of any active clients, be they tabs or background processes.
Proper service workers take advantage of the event life cycle to manage data, like cached responses, to set the service worker context.
The podcast application...