[ServiceWorker] seems possible to trigger many update fetches after 24 hour limit expires (#759)

Step 7 of Handle Functional Event checks the last update time:

> If the time difference in seconds calculated by the current time minus registration's last update check time is greater than 86400, invoke Soft Update algorithm, or its equivalent, with registration.

Step 13 of the Update algorithm ultimately sets the last update time:

> If response's cache state is not "local", set registration's last update check time to the current time.

Of course, it only does this after the async step 11:

> Let response be the result of running fetch using r.

While waiting for the fetch you may end up with multiple update requests queued.

Now each update will run sequentially thanks to step 4.1 doing the CheckPriority step, but they will each attempt a network fetch.  I guess http cache may avoid the network hit here, but we're still doing a lot of extra work.

Can we somehow de-bounce these updates?  Like don't queue updates for the 24 hour expiration unless the queue is empty?  This would let .update() still force another update, but avoid a burst of events triggering a lot of soft updates.

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

Received on Tuesday, 13 October 2015 21:11:44 UTC