Re: [ServiceWorker] should update on navigation or the subsequent updatefound event be delayed until document DOM is loaded? (#788)

Chrome's implementation tries to schedule the updates after the worker stops:
- Schedule an update 1 second after page load for a navigation in a SW's scope.
- Whenever the active worker stops, if it hasn't attempted an update in 24 hours, and no update is scheduled, schedule an update.
- If the active worker has been running without stopping for 5 minutes, if hasn't attempted an update in 24 hours, and no update is scheduled, schedule an update.

Scheduling an update pushes back the timer.

I implemented this before the spec required Soft Updates at the end of each event. I wanted to wait for the worker to stop to avoid situations where the worker triggers an update and skipWaiting() kills it while it's in middle of an event (Chrome doesn't wait for the active worker to be finish in-progress requests... that's a bug). But as it's approximately the same as the spec (the rough result is a Soft Update approx every 24 hours), I probably wouldn't expend much effort to get it to exactly match unless there's a real benefit for devs.


---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/788#issuecomment-173839107

Received on Friday, 22 January 2016 08:08:35 UTC