Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back/foraward cache NotRestoredReasons API #93

Closed
rubberyuzu opened this issue Mar 31, 2023 · 4 comments
Closed

Back/foraward cache NotRestoredReasons API #93

rubberyuzu opened this issue Mar 31, 2023 · 4 comments

Comments

@rubberyuzu
Copy link

Introduction

Currently developers can tell whether BFCache is being used or not but they cannot tell what reasons are blocking it from being used and what actions to take to improve their hit-rate. DevTools provide the testing feature to tell developers what reasons are blocking, but that is only for lab testing and not for gathering the data from the wild.

One way to solve this issue would be to provide an API to report the reasons why the page was not restored from bfcache if not.
One idea is to extend PerformanceNavigation API to include this information as below:

window.addEventListener("pageshow", (event) => {
  if (!event.persisted) {
    const navEntries = performance.getEntriesByType("navigation");
    for (var i=0; i < navEntries.length; i++) {
	console.log("= Navigation entry[" + i + "]");
	var p = navEntries[i];
	// p.notRestoredReasons == [{url:"a.com", id: "x", blocked: true, reasons:["Broadcast channel"], children:[]}]
    }
  }
});

It will have notRestoredReasons field that will contain the reasons in the frame tree structure.
Note that this would risk exposing cross-site information, so we should avoid reporting reasons from the cross-origin subframes.

Read the complete Explainer.

Feedback

I welcome feedback in this thread, but encourage you to file bugs against the Explainer.

@rubberyuzu
Copy link
Author

Position requests for Mozilla and WebKit.
This is the discourse discussion.

@yoavweiss
Copy link
Collaborator

Mozilla seems fine with this repo moving to the WICG org.

@nicjansma
Copy link

We would like to have notRestoredReasons for our RUM measurements in Akamai mPulse.

We are starting to track BFCache-based navigations, and with that our RUM customers will become more interested in why specific navs were not BFCache-eligable. Gathering this information will be a huge help in pointing out the culprits in aggregate.

@yoavweiss
Copy link
Collaborator

The repo is now live at https://github.com/WICG/bfcache-not-restored-reason

Happy incubation!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants