Service worker Install event vs Activate event

Viewed 3829

This is regarding the serviceworker API that is used in Progressive Web App. Can anyone help me to understand the difference between Service worker install event and activate event?

Following are my understanding,

  1. Install event is the first event that occurs after registering the service worker.
  2. Install event only happens once - I'm not sure about this, i can see this event runs when page gets refreshed. So I'm confused with that statement.
  3. After the install event - activate event triggers.
  4. Activate event triggers every time when page reloads.

Apart from above statement, my question is what exactly the difference between two events, they both run one after another, if so why we need two events ?

Update: Sharing the resource which might help. I'm reading this. https://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle

Thanks for all the response.

1 Answers
Related