Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The reason for onSuccess being executed instead of onUpdate in the service worker is that onUpdate is called when the service worker script is updated and the new version is installed in the browser. However, the new version is not activated until all pages using the previous version are closed. This means that onUpdate will not be executed until the next time the page is opened or reloaded.

On the other hand, onSuccess is executed when the new version of the service worker is installed and immediately activated, meaning that it is ready to take control of the pages that are currently open. This is why onSuccess is typically used to update the cached content or perform other tasks that need to be done immediately after the new service worker version is installed and activated.