Back/forward cache NotRestoredReasons API

Contact: bfcache-dev@chromium.org

This document describes the status of the current implementation of the NotRestoredReasons API in Chrome, and how to enable it.

Starting from version 108, Chrome experimentally supports NotRestoredReasons API. This allows sites to access what reasons are preventing their pages from being restored from back/forward cache..

Note that this API is not available by default. Chrome plans to do an origin trial to evaluate its effectiveness and to allow site authors to give feedback.

What’s supported

A new field notRestoredReasons is added to performanceNavigationTiming API. This new field will report the reasons that prevented back/forward cache on the page in a frame tree structure.

Activation

The policy can be enabled in several ways.

Using the Chromium UI

Enable the flag chrome://flags/#enable-experimental-web-platform-features . You also have to enable back/forward cache flag via chrome://flags/#back-forward-cache .

Using Origin Trial

The Origin Trial feature is named NotRestoredReasons. Registration for the trial is here. See feature status to find out if the origin trial is currently running.

The origin trial tutorial describes how to participate.

Verifying the API is working

In devtools, run the following piece of javascript after navigating to a page, and clicking back/forward button.

performance.getEntriesByType('navigation')[0].notRestoredReasons;

If it gives you a value, it succeeds. If it gives undefined then the feature is not enabled.

Related Links