Test back/forward cache

Sofia Emelianova
Sofia Emelianova

This guide shows you how to useChrome DevTools to do the following:

  • Test if you optimized your page for instant loads when using the browser's back and forward buttons.
  • Identify issues that may prevent your page from being eligible for this type of caching.

Back/forward cache (or bfcache) is a browser optimization that enables instant back and forward navigation. For more information, seeBack/forward cache.

Key point: Back/forward cache differs from browsercache andHTTP cache.

To inspectcache data, follow the steps inView cache data.

To inspectHTTP cache data, open theSize column of theNetwork Log. SeeLog network activity.

Test back/forward cache

To test back/forward cache, follow these steps:

  1. On your page,open DevTools, then navigate toApplication >Background services >Back/forward cache.

    Back/forward cache tab.

  2. ClickTest back/forward cache.

    Chrome automatically takes you tochrome://terms/ and back to your page.

    Alternatively, you can click the browser's back and forward buttons.

If the back/forward cache works for your page with no issues, you'll see the following message:

Successfully served from back/forward cache.

Otherwise, you'll see a list of issues.

To find out which issues affect which frames, expand theFramesExpand icon. section.

Expanded Frames section.

Resolve issues that prevent caching

If your page isn't eligible for back/forward caching, theBack/forward cache tab shows you a list with three types of causes:

Not eligible for back/forward cache.

  • Actionable. You can fix these issues to enable caching. For example,stop usingunload events.
  • Pending Support. Chrome doesn't support these features yet, so they prevent caching. However, once supported, Chrome removes these limitations.
  • Not Actionable. You can't fix these issues on this page. Something that is outside the page's control prevents caching.

To find out which frame is the blocker, expand the corresponding section under the issue's description.

Blocking frames.

Common issues that prevent back/forward caching

The two main reasons that prevent bfcache from running are:

  • Cache-Control: no-store header.

    This header value is recommended for pages with personal and private information. For pages you want to be reasonably fresh, useno-cache or a short cache time, for example,max-age=60.

  • Problematic unload handlers.

    Chrome is planning todeprecate unload handlers and recommends to never use anunload event.

    To ensure that your website doesn't use unload handlers and, for example, prevent extensions from addingunload events, declare thePermissions-Policy: unload=() HTTP response header.

Tip: To test a bfcache fix, you canmock a response header with overrides.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-05-04 UTC.