Feature Description
New to the web platform is the fetchLater() API. See WICG docs.
Where I see this as being useful is that now with #1959, Optimization Detective is preparing the compressed JSON Blob to be sent to the url-metrics:store endpoint, which gets triggered at the pagehide event (unless an extension is using a deprecated finalize function per #1951). Whenever the URL Metric is modified, the Blob of the URL Metric gets re-compressed after 1 second of debouncing (including the use of an idle callback and a timeout). There's a possibility for fetchLater to fit in here nicely, where whenever the URL Metric is re-compressed into the Blob, it could then at that point call fetchLater to queue the blob to be sent when the page is closed. At this point, it could abort any other any existing fetchLater which is pending, as seen in the docs example. When this is done, we could eliminate the use of pagehide to send the URL Metric data.
As I understand, this should greatly improve the reliably of sending the URL Metric data, since the pagehide event often never fires on mobile. However, from testing done last year, it was not seen to be particularly more reliable than sendBeacon at pagehide. Maybe it has become more reliable since. This is something to investigate further.
The use of fetchLater was previously mentioned in #1311 (comment).
See also:
Feature Description
New to the web platform is the
fetchLater()API. See WICG docs.Where I see this as being useful is that now with #1959, Optimization Detective is preparing the compressed JSON
Blobto be sent to theurl-metrics:storeendpoint, which gets triggered at thepagehideevent (unless an extension is using a deprecatedfinalizefunction per #1951). Whenever the URL Metric is modified, theBlobof the URL Metric gets re-compressed after 1 second of debouncing (including the use of an idle callback and a timeout). There's a possibility forfetchLaterto fit in here nicely, where whenever the URL Metric is re-compressed into theBlob, it could then at that point callfetchLaterto queue the blob to be sent when the page is closed. At this point, it could abort any other any existingfetchLaterwhich is pending, as seen in the docs example. When this is done, we could eliminate the use ofpagehideto send the URL Metric data.As I understand, this should greatly improve the reliably of sending the URL Metric data, since the
pagehideevent often never fires on mobile. However, from testing done last year, it was not seen to be particularly more reliable thansendBeaconatpagehide. Maybe it has become more reliable since. This is something to investigate further.The use of
fetchLaterwas previously mentioned in #1311 (comment).See also: