Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Explore use of the fetchLater API should be used instead of using keepalive fetch at pagehide when available #1970

@westonruter

Description

@westonruter

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:

Metadata

Metadata

Assignees

Labels

No fields configured for Enhancement.

Projects

Status
Not Started/Backlog 📆

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions