Search code examples
service-workerweb-push

Can a service worker be updated thanks to a push event?


I know the question was first raised here and lately discussed there:

I think we should define that:

[...]

We do a "update check" any time a SW handles an non-fetch/non-message event, such as events for an incoming push message or geofencing message. These might not trigger a navigation so it's important that these also do update checks.

[...]

When we fire an event in the SW, we should trigger a soft update if we haven't done one within 24hrs

The W3C specs are kind of vague to me (SW Update, SW Soft Update), as of today can a service worker be updated after a push event ? Are Chrome / Firefox / Safari following the same behavior ?


Solution

  • In Firefox, the answer is yes. It was implemented here: https://bugzilla.mozilla.org/show_bug.cgi?id=1207727. You can inspect the changeset, in particular in the ServiceWorkerPrivate.cpp file here: https://bugzilla.mozilla.org/page.cgi?id=splinter.html&bug=1207727&attachment=8678641.

    Safari doesn't support service workers or the push API, so the answer here is no.