title | maintainer | created | updated |
---|---|---|---|
How to experiment with BFCache NotRestoredReasons in Chrome |
yuzus |
10/11/2022 |
10/11/2022 |
NotRestoredReasons API is a part of PerformanceNavigationTiming API. You can access why a apge is not restored from BFCache like below:
performance.getEntriesByType('navigation')[0].notRestoredReasons;
This will get you the results like this:
{
url:"a.com",
src: "a.com",
id: "x",
name: "x",
blocked: false,
reasons:[],
children: [
{url:"a.com", src: "a.com", id: "y", name: "y", blocked: false, reasons:[], children: []},
{url:"", src: "b.com", id: "z", name: "z", blocked: true, reasons:[], children: []}
]
}
Read more about the API here: Explainer
- Download a version of Chrome with NotRestoredReasons implemented. (Link for Canary channel)
- Launch Chrome with the command line flag --enable-features=BackForwardCacheSendNotRestoredReasons. (Instructions for different platforms.)
When the flag is on, NotRestoredReasons field is always present. It is only populated when a page is not restored from BFCache though.
Navigate to a page, go away from the page and go back to it. (A.com -> B.com -> A.com) If A.com is not restored from BFCache, you will see the notRestoredReasons field populated. If not, it will be empty.
performance.getEntriesByType('navigation')[0].notRestoredReasons;