Check 06.26 · Performance and Core Web Vitals

Make pages eligible for the back/forward cache (bfcache)

Test whether your pages are eligible for the back/forward cache (bfcache), remove the blockers (unload, no-store, open connections) and measure the result.

Priority
Important
Difficulty
Intermediate
Estimated time
2 h to 1 day
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

The bfcache (back/forward cache) keeps an entire page in memory, JavaScript state included, when the visitor leaves it. If they come back with the Back or Forward button, the browser restores it as it was, with no request and no rendering. Chrome, Firefox and Safari all have one. The work consists of checking that nothing in your pages prevents them from being stored this way, then handling the restore correctly.

Why it matters

The HTTP cache only stores responses: on a back navigation, the browser still has to re-read the HTML, run the scripts again and repaint the page. The bfcache, by contrast, freezes the complete page and suspends its JavaScript. The restore is almost instant, and the visitor gets back their scroll position and the fields they had filled in.

It is a common case: product list, product page, back to the list; internal search results, article, back. But the browser only uses it if it considers the operation safe. Several things prevent it, depending on the browser:

Cause Status as of November 2026
unload event handler Chrome no longer fires unload by default now that its deprecation is complete (100% of page loads from Chrome 155). Firefox, for its part, long excluded pages that listen for it: stop using it
Cache-Control: no-store on the document Blocking by default. Chrome now restores these pages when it considers it safe (no cookie change in the meantime, in particular), with a shorter retention time. Other browsers may keep blocking
Open connections (IndexedDB, fetch() in progress, WebSocket, WebRTC) Varies by browser and API: close them when the page is left
Non-null window.opener Page opened by window.open() or a link without noopener: can block the page and the one that opened it
Iframe that uses a blocking API Also blocks the page that embeds it

These rules change from one version to the next: rely on the test described below and on the web.dev and Chrome pages linked at the bottom of this guide rather than on a fixed list.

Good to know: in a single-page application, route changes handled by the JavaScript router do not go through the bfcache. It only concerns navigations handled by the browser.

What it improves

  • Back and forward navigations Instant display, with no network request.
  • Core Web Vitals These restores count in Chrome's field data, with a very short LCP (Largest Contentful Paint, rendering of the largest visible element). CrUX distinguishes navigation types, which lets you see their share.
  • Server load A restore requests no document from the server.
  • Rankings Indirect and modest effect, through Core Web Vitals, one signal among many others. Crawlers do not navigate back.
  • Analytics Be careful, a restore does not reload the page. Without adaptation, some tools do not count that page view.

How to check

In Chrome, open DevTools, Application panel, Background services > Back/forward cache section, then click Test back/forward cache. Chrome leaves the page and then comes back to it. Compliant result: “Successfully served from back/forward cache”. Otherwise, the reasons are sorted into three groups:

  • Actionable: to be fixed in the page (for example an unload handler);
  • Pending Support: a feature that Chrome cannot cache yet;
  • Not Actionable: a cause outside the page.

The Frames section shows which iframe is responsible. Test one template of each type, logged in and logged out, and without browser extensions (guest profile): an extension can skew the result.

Check the document's header too:

curl -s -o /dev/null -D - https://example.com/ | grep -i "cache-control"

A response that contains no-store needs a closer look. Lighthouse also has an audit dedicated to the bfcache: see analyze PageSpeed Insights and Lighthouse (opens in a new tab).

Finally, check in Firefox and Safari: navigate, go back, and see whether this code logs true.

window.addEventListener('pageshow', (event) => {
  console.log('Restored from the bfcache:', event.persisted);
});

How to implement

Replace unload with pagehide

Search for unload in your code and in the code of the libraries you ship (addEventListener('unload', window.onunload). Replace it with pagehide, or with visibilitychange to send analytics data: it is the last reliable moment on mobile.

window.addEventListener('pagehide', (event) => {
  fermerConnexions();
});

document.addEventListener('visibilitychange', () => {
  if (document.visibilityState === 'hidden') {
    navigator.sendBeacon('/mesure', JSON.stringify(donnees));
  }
});

Only add beforeunload when there really are unsaved changes, and remove it as soon as they are saved.

Third-party scripts are often the culprits. The Permissions-Policy: unload=() header forbids any unload handler in the page and its iframes. It is only recognized by Chromium browsers, where it has become the default behavior: it is now only useful for earlier versions of Chrome. For other browsers, the only solution is still to remove or replace the script. See limit third-party scripts (opens in a new tab).

Keep no-store for the pages that require it

no-store is justified for genuinely sensitive pages (bank account, medical record). For a page that simply has to stay up to date, Cache-Control: no-cache or max-age=0 is enough: the browser revalidates with the server on every load, without giving up the bfcache. See configure browser and server caching (opens in a new tab).

Close connections and reopen them on return

let canal = ouvrirWebSocket();

window.addEventListener('pagehide', () => {
  canal.close();
});

window.addEventListener('pageshow', (event) => {
  if (event.persisted) {
    canal = ouvrirWebSocket();
  }
});

Do the same for IndexedDB connections and abort long-running fetch() requests. Add rel="noopener" to links that open a new window if your templates target old browsers.

Refresh what may have changed

A restored page shows the state it had before the visitor left. Update whatever depends on the session when pageshow fires:

window.addEventListener('pageshow', (event) => {
  if (! event.persisted) {
    return;
  }

  actualiserCompteurPanier();

  if (! document.cookie.includes('session_active=')) {
    location.reload();
  }
});

The cookie test assumes a cookie readable in JavaScript, set at login and deleted at logout: adapt its name. For analytics, send a page view in this same handler if your tool does not do it: see set up GA4, Matomo or an equivalent (opens in a new tab). Ad slots are refreshed in the same way.

Measure in the field

The notRestoredReasons API gives, for a back or forward navigation that did not use the bfcache, the list of reasons, iframes included. It has been available in Chrome since version 123; check the other browsers on MDN.

window.addEventListener('pageshow', (event) => {
  const navigation = performance.getEntriesByType('navigation')[0];

  const mesure = {
    page: location.pathname,
    type: event.persisted ? 'back_forward_cache' : navigation.type,
    motifs: [],
  };

  if (! event.persisted && navigation.type === 'back_forward') {
    mesure.motifs = (navigation.notRestoredReasons?.reasons ?? []).map((motif) => motif.reason);
  }

  navigator.sendBeacon('/rum', JSON.stringify(mesure));
});

The hit rate is calculated as follows: back_forward_cache restores divided by the total of back_forward_cache + back_forward. Do not expect 100%: a duplicated tab, a closed browser or an expired timeout make some restores fail. The reason labels change between Chrome versions: group them without hard-coding them.

Apache

Versions Apache 2.4 (mod_headers).

First find where no-store is added:

grep -R -n -i "no-store" /etc/apache2/ /var/www/example/.htaccess

If the directive comes from Apache and targets public pages, replace it, in the virtual host or the .htaccess:

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
    Header set Permissions-Policy "unload=()"
</IfModule>

The first line replaces the header on all HTML: restrict it with a <LocationMatch> block if some pages must keep no-store. If the Permissions-Policy header already exists, add unload=() to its value instead of creating a second one. Reload with sudo apachectl configtest && sudo systemctl reload apache2.

Nginx

Versions Nginx 1.18 and later.

grep -R -n -i "no-store" /etc/nginx/

In the location block that serves the HTML:

add_header Cache-Control "no-cache";
add_header Permissions-Policy "unload=()";

If the Cache-Control header comes from the application (PHP, Node.js), fix it in the application: add_header would add a second header instead of replacing the first. Reload with sudo nginx -t && sudo systemctl reload nginx.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

Cloudflare passes the origin's Cache-Control header on to the browser. If you cannot fix the origin, a response header transform rule can rewrite it or add Permissions-Policy: Rules > Overview (rules overview). Limit the rule to public pages and test again in DevTools.

WordPress

Versions WordPress 6.8 and later.

Public pages viewed by a logged-out visitor do not get no-store from core. However, all “nocache” responses have carried it since WordPress 6.8: the admin, logged-in users, and the pages that plugins declare non-cacheable (cart, checkout and account of a store). On those pages, back navigation therefore depends on the browser.

  • A core ticket proposes making the bfcache possible for logged-in users; the Instant Back/Forward plugin applies this approach. Check their status before installing anything.
  • Test the site with plugins active: live chat, advertising and old jQuery libraries add unload handlers. The DevTools test names the script responsible.
  • A caching plugin changes nothing for the bfcache: it all happens in the browser.

Laravel

Versions Laravel 11 to 13.

Out of the box, a Laravel response is sent with Cache-Control: no-cache, private, which is compatible with the bfcache. Look for what adds no-store:

grep -R -n "no-store\|no_store" app/ config/ routes/

A security middleware or a third-party package sometimes applies it to every route: limit it to sensitive pages. After a logout, handle back navigation with the pageshow handler above.

Next.js

Versions Next.js 15 and 16 (App Router).

Internal navigations go through the client-side router and do not involve the bfcache. It comes into play when the visitor leaves the site and then comes back with the Back button. In that case, check the document's header with curl: depending on the route's rendering mode (static or on demand), Next.js does not send the same Cache-Control. If an on-demand route responds with no-store for no reason, see whether it can be rendered statically or revalidated; the Next.js caching documentation describes both cases.

Common mistakes

  • Setting no-store everywhere “for security”: public pages lose the bfcache in some browsers, with nothing protected in return.
  • Testing with your extensions active: they inject their own scripts and skew the diagnosis.
  • Testing only in Chrome: Chrome has become the most lenient (unload, no-store). A page that passes in Chrome may still be blocked elsewhere.
  • Forgetting stale state: cart, login status or stock shown as they were when the visitor left. Refresh them on pageshow.
  • Reading notRestoredReasons as proof of a restore: a null value does not mean the bfcache was used. Only event.persisted tells you that.
  • Believing that pagehide with persisted set to true guarantees caching: the browser intends to keep the page, but is under no obligation to.
  • Confusing it with preloading: the bfcache only handles returns. For forward navigations, see preload navigations with Speculation Rules (opens in a new tab).

Frequently asked questions

What is the difference between the bfcache and the HTTP cache?

The HTTP cache keeps network responses: HTML, CSS, images. On a back navigation, the browser still has to parse the HTML, run the scripts and repaint the page. The bfcache keeps the whole page in memory, JavaScript state and scroll position included, and restores it with no request and no rendering. The two are independent: a page can be absent from the HTTP cache and present in the bfcache.

Does Cache-Control: no-store always prevent the bfcache?

Not always any more. Historically, a document served with Cache-Control: no-store was excluded from the bfcache. Chrome now restores these pages when it considers it safe, for example if cookies have not changed since the visitor left, and keeps them for a shorter time. Other browsers may keep excluding them. For a public page that has to stay up to date, prefer no-cache or max-age=0.

Does the bfcache improve SEO?

Indirectly and modestly. Restores from the bfcache are counted in Chrome's field data with very short display times, which improves the site's Core Web Vitals. These are one ranking signal among many others. Crawlers do not go back: the benefit is first and foremost for visitors, on round trips between listing pages and detail pages.

How do I find out why a page is not stored in the bfcache?

In Chrome, open DevTools, Application panel, Back/forward cache section, and run the test: the reasons are displayed, sorted by whether or not you can fix them, along with the iframe responsible. In the field, the notRestoredReasons property of the navigation entry gives the same reasons for real visits, in the browsers that support it.

Are page views counted when a page is restored?

Not necessarily. A restore from the bfcache does not reload the page: scripts do not run again, and an analytics tool that sends the page view on load sees nothing. Listen for the pageshow event and, when event.persisted is true, send the page view yourself if your tool does not do it. Check its documentation to avoid double counting.

Updated on

Topic checklist (PDF)

And now?

In the “Performance and Core Web Vitals” topic

  1. Analyze PageSpeed Insights and Lighthouse
  2. Analyze real-user CrUX data
  3. Target LCP ≤ 2.5 s at the 75th percentile
  4. Target INP ≤ 200 ms at the 75th percentile
  5. Target CLS ≤ 0.1 at the 75th percentile
  6. Target TTFB ≤ 800 ms as a benchmark
  7. Optimize hosting and CDN
  8. Enable Brotli/Gzip
  9. Configure browser and server caching
  10. Minify CSS and JavaScript
  11. Remove unused CSS/JS
  12. Reduce render-blocking resources
  13. Defer non-essential scripts
  14. Limit third-party scripts
  15. Optimize database queries
  16. Optimize fonts (WOFF2, font-display)
  17. Preload only critical resources
  18. Optimize the LCP image without lazy loading
  19. Lazy-load offscreen content
  20. Reserve space for media and ads
  21. Reduce DOM complexity
  22. Test before and after cookie consent
  23. Test on a slow mobile connection
  24. Set a performance budget
  25. Preload likely navigations with Speculation Rules
  26. Make pages eligible for the back/forward cache (bfcache)
  27. Diagnose INP with Long Animation Frames (LoAF)