Lighthouse: Allow back/forward cache restoration
Overview
The back/forward cache (bfcache) is an in-memory browser cache that enables near-instant backward and forward navigation when using the browser's backward and forward buttons.
Allowing your page to be restored from the bfcache can help ensure a speedy experience to repeat visitors.
How does your site score on this audit?
How does allowing back/forward cache restoration affect page performance?
In a nutshell, it ensures frequent visitors to your page have the fastest possible experience.
The bfcache stores a complete snapshot of your page (including JavaScript heap) as the user is navigating away. This is akin to "pausing" your page when navigating away, and then "resuming" when you return to it.
We've all been in situations where we visit a page and then click on a link to go to another page, but we realize that's not the page we really want and click the back button to return to the first page.
It is these kinds of navigations (particularly on mobile devices) where bfcache is very beneficial to page performance as it can retrieve whole pages quicker than the browser's HTTP cache.
If your page cannot be restored from the bfcache, you're likely depriving your visitors of the opportunity to experience near-instant navigations when using the browser's backward and forward buttons.
In addition, depending on how well your page is optimized for repeat visits, your page and its assets may have to be downloaded, parsed, and executed again, which may create longer page load times.
Restoring your page from bfcache provides a speedy experience to your visitors, particularly those on slower networks/devices.
Your page assets also don't have to be sent over the network again, reducing data usage for your visitors as well.
How does GTmetrix trigger this audit?
GTmetrix tests if your page can be restored from the bfcache by navigating away and attempting to restore the page from the navigation history.
If your page could not be restored from the bfcache, this audit is triggered and the reason(s) for the failed restoration are displayed.
Failure reasons fall under one of three types, as listed below:
- Actionable: You can fix these issues to enable the bfcache.
- Pending browser support: Caching is prevented by Google's Chrome browser not supporting these features yet. Once Chrome gains support for these features, bfcache should be enabled.
- Circumstantial: Fixing these issues may be harder as it is usually not related to your page code itself and so may be outside your control. Look at the failure reason details for more insight.
How to fix this audit?
If the audit is triggered for a reason classified as Actionable (e.g., using unload event listeners), fixing that issue should fix the audit.
Note that you may not be able to fix this audit if the failure reason is circumstantial or pending browser support.
In that case, you can ignore this audit as it focuses mainly on repeat visitors and is not concerned with your page's first load.
Refer to this external resource for more information on the bfcache.