New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 902444 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Consider periodically updating service workers in the background (based on heuristics like site engagement metrics)

Project Member Reported by joelriley@google.com, Nov 6

Issue description

Currently service workers only check for updates (updated service worker file) when you visit a controlled page.

Common scenario with service worker controlled pages (such as PWAs):

1.) Visit SW-controlled page
2.) Page is served from SW cache of currently installed SW
3.) New SW is detected, it is installed in the background while user is on page
4.) New SW updates resources in cache
5.) SW-controlled page gets 'controllerchange' event if new SW skips waiting
6.) SW-controlled page must now continue with now-stale site, reload the page forceably, or prompt the user to do so.

This results in a sub-par user experience, especially for PWAs that update fairly regularly. It would be great if checks for new service workers and kicking off the install process could happen periodically in the background, at least for frequently used PWAs. This will reduce the gap between PWAs and native apps.
 
Status: Available (was: Untriaged)
Summary: Consider periodically updating service workers that have high site engagement (was: Allow service workers to update in the background)
I see. We could consider triggering a periodic update check for frequently used service workers.

You're right that there is currently no periodic service worker update check. However service worker updates are triggered in more cases than visiting a controlled page. Running a service worker can triggers an update if it hasn't been updated in a while (24 hours). So, e.g., if you get a push notification, by the time you tap the notification the worker may have already been updated.

The idea is that unused service workers shouldn't incur network/cpu costs, even for the update check. But we could potentially hook into site engagement  and do periodic updates even when the SW isn't being used. I'm not sure the latest story on site engagement.
Cc: jakearchibald@chromium.org
This should probably be discussed as a spec issue.

And I think the spec might have used to have automatic updates in the background but it was removed from the spec.  For example this issue mentions "controllers must be checked every 24 hours":

https://github.com/w3c/ServiceWorker/issues/43

Jake, do you recall why it was removed?
I think the spec permits it in Soft Update: "The user agent may call this as often as it likes to check for updates."
True, but it feels like an interop issue if sites have to deal with update-on-navigate for some browsers, but get background update for other browsers.
Ah I thought we'd still do update-on-navigate all the time, and in addition to that sometimes do spontaneous Soft Update for frequently used SWs.
Also want to mention that "Add to homescreen" could be another useful signal in addition to high engagement to determine soft update eligibility. Users could use an web app only occasionally but think it is important enough to install to their device and may want an up-to-date version when they do launch it.
Summary: Consider periodically updating service workers in the background (based on heuristics like site engagement metrics) (was: Consider periodically updating service workers that have high site engagement)
Cc: kenjibaheux@chromium.org
Kenji: Adding for PM visibility to help gauge priority.

Sign in to add a comment