Summary
Back/forward cache(BFCache) is cache optimization that some browser implement to make back/forward button navigation instant.
Today pages can be blocked from BFCache for different reasons, such as reasons required by spec and reasons specific to the browser implementation.
Developers can gather the hit-rate of BFCache on their site by using the pageshow handler persisted parameter and PerformanceNavigationTiming.type(back-forward). However, there is no way for developers to tell what reasons are blocking their pages from BFCache in the wild.
We would like to expand Reporting API and Performance Navigation Timing API to make it possible for sites to collect information on why BFCache is not used on a history navigation, so that they can take actions on each reason and make their page BFCache compatible.
Example
Reporting API lets you observe a deprecated feature usage / browser request intervention / crashes. We would like to have another category “bfcache” here.
Report-To: {
"max_age": 10886400,
"endpoints": [{
"url": "a.com"
}]
}
// -> [{URL:"a.com", Id: "x", blocked: True, reasons:["broadcast channel"], children:[]}]
Performance Navigation Timing API tells you the type of navigation (BFCache, prerender). We could also extend this API to report the not-restored reasons.
var perfEntries = performance.getEntriesByType("navigation");
for (var i=0; i < perfEntries.length; i++) {
console.log("= Navigation entry[" + i + "]");
var p = perfEntries[i];
// p.notRestoredReason == [{URL:"a.com", Id: "x", blocked: True, reasons:["broadcast channel"], children:[]}]
}