Open mingyc opened 1 year ago
I'd like to share some feedback regarding how reliably fetchLater
posts data, hoping this is the right issue for that.
Using the Chrome Origin Trial, we from Speed Kit found:
activateAfter
option), which was higher than sending beacons on unload
, beforeunload
, pagehide
, or visibilitychange
.That said, we did not test reliability together with preloading (e.g. via Speculation Rules), nor did we try to change or cancel fetchLater
requests, nor did we experiment with different activateAfter
times.
I've had a chance now to look at fetchLater()
's reliability as well, and compared it to my previous experiments with Pending Beacon.
Details here:
https://nicj.net/beaconing-in-practice-fetchlater/
TL;DR:
.sendNow()
when doing { timeout: 0 }
. onload
, fetchLater()
is slightly more reliable than sendBeacon()
(< 1% difference)pagehide
or visibilitychange[hidden]
, sendBeacon()
is slightly more reliable than fetchLater()
(~1% better). It’s probably worthwhile to look into this a bit further why.fetchLater()
gives some developer ergonomics with activateAfter
that results in more reliable beacons than listening to unload handlersI’m really excited for the fetchLater() API. It’s giving developers better ergonomics for sending data, and a more reliable way to send beacons at the end of the page lifetime.
Current spec proposal https://github.com/whatwg/fetch/pull/1647 does not include anything about reliability.
The question about "How reliable fetchLater should be" has been brought up again during Chromium implementation. Quoted from the discussion:
Note that retry & recovery from storage are also in the following issues: