Skip to content

Latest commit

 

History

History
44 lines (39 loc) · 1.72 KB

HowToTest.md

File metadata and controls

44 lines (39 loc) · 1.72 KB
title maintainer created updated
How to experiment with BFCache NotRestoredReasons in Chrome
yuzus
10/11/2022
10/11/2022

How to experiment with BFCache NotRestoredReasons in Chrome

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

Enabling NotRestoredReasons in Chrome

  1. Download a version of Chrome with NotRestoredReasons implemented. (Link for Canary channel)
  2. Launch Chrome with the command line flag --enable-features=BackForwardCacheSendNotRestoredReasons. (Instructions for different platforms.)

How to access the NotRestoredReasons value

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;