There are two types of service worker events: core and functional. Core messages are fundamental to what makes a service worker a service worker. Functional events can be thought of as extensions to the central service worker backbone:
Core Events:
- Install
- Activate
- Message
Functional Events:
- fetch
- sync
- push
Each of these events can be used to trigger processing. The install and activate events are part of the life cycle. In Chapter 7, Service Worker Caching Patterns, we will dive into different caching patterns. The install and activate events are very useful to manage pre-caching assets and cleaning up your cache model.
When a new service worker is registered, the install event immediately triggers. The activate event triggers when the service worker becomes active. This means that any existing service worker is replaced with the new service worker.
...