大网数据广告活动
Web 标准与前端开发

PerformanceNavigationTiming: notRestoredReasons property

· 52CE 我爱测

The **`notRestoredReasons`** read-only property of the PerformanceNavigationTiming interface returns a NotRestoredReasons object providing report data on the reasons why the current document was blocked from using the back/forward cache (bfcache) on navigation.

Performance API

The notRestoredReasons read-only property of the PerformanceNavigationTiming interface returns a NotRestoredReasons object providing report data on the reasons why the current document was blocked from using the back/forward cache (bfcache) on navigation.

Value

When the associated PerformanceNavigationTiming object represents a history navigation, notRestoredReasons returns a NotRestoredReasons object.

When the PerformanceNavigationTiming object does not represent a history navigation, notRestoredReasons will return null. This is useful to determine whether bfcache is not relevant to a particular navigation (as opposed to notRestoredReasons not being supported, in which case it would return undefined).

The notRestoredReasons property may return null even when the navigation type is reported as back/forward. The circumstances under which this happens include:

  • Duplicating a back/forward navigation in a new tab. In such cases, some browsers copy the navigation type from the original tab, but as these are not actually back/forward navigations, notRestoredReasons returns null.
  • Restoring a back/forward navigation tab after a browser restart. Since the bfcache stores fully loaded pages including DOM and JavaScript heap, developers cannot make bfcache survive a full restart. The property therefore returns null because there was no bfcache entry to block restoration in the first place.

Examples

PerformanceNavigationTiming data can be obtained from the performance timeline using Performance.getEntriesByType() or PerformanceObserver.

For example, you could invoke the following function to return all PerformanceNavigationTiming objects currently present in the performance timeline and log their notRestoredReasons:

function returnNRR() {
  const navEntries = performance.getEntriesByType("navigation");
  for (let i = 0; i < navEntries.length; i++) {
    console.log(`Navigation entry ${i}`);
    let navEntry = navEntries[i];
    console.log(navEntry.notRestoredReasons);
  }
}

The PerformanceNavigationTiming.notRestoredReasons property returns an object with the following structure, which provides reasons why the current document was blocked from using the bfcache. In this example the top-level frame has no embedded child <iframe>s:

{
  "children": [],
  "id": null,
  "name": null,
  "reasons": [{ "reason": "unload-listener" }],
  "src": "",
  "url": "example.com"
}

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。