w3c / navigation-timing

Navigation Timing
https://w3c.github.io/navigation-timing/
Other
116 stars 30 forks source link

Extend the navigationType enum to include "reload after being discarded" navigations #178

Closed yoavweiss closed 2 years ago

yoavweiss commented 2 years ago

See https://bugs.chromium.org/p/chromium/issues/detail?id=1320480

On some platforms, the browser can discard backgrounded tabs from memory, resulting in them being reloaded if & when the user goes back to them. Currently there's no way to distinguish those reloads from user-initiated ones. It'd be good if there was, to enable developers understand which portion of their pages get discarded in the background, and optimize for that (e.g. by improving their caching, etc).

yoavweiss commented 2 years ago

Turns out that there's already a (chromium-only, unspecified) API called document.wasDiscarded that provides that signal.

yoavweiss commented 2 years ago

Apologies but it looks like the API is specified in https://wicg.github.io/page-lifecycle/#dom-document-wasdiscarded

yoavweiss commented 2 years ago

And from the Chromium issue, it seems like wasDiscarded provides a sufficient signal for now. Closing!