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,
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.
The install event only fires when the service worker file is found to be new - either different to an existing service worker (byte-wise compared), or the first service worker encountered for this page/site.
It is good practice to cache any static files that your application may need, this means your application won't have to download these files unless they are updated.
If there is already an active service worker, the new service worker will be installed in the background - but not made active until there are no pages still using the old service worker.
The activate event will fire every time you make connection to your service worker. This is a good place to cache any extra (possibily dynamic) files, along with cleaning up old caches and things associated with the previous version of your service worker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With