If you're running an online store on Magento, you know how important it is to provide your customers with a fast and responsive website. Slow load times and poor user experience can lead to lost sales and decreased customer satisfaction. Poor performance also directly impacts your Google Core Web Vitals (CWV), affecting SEO rankings. That's where bfcache comes in…

Back/Forward Cache (bfcache): Performance-Booster for Magento 2 Back/Forward Cache (bfcache): Performance-Booster for Magento 2

 

“bfcache powers the rapid flow,
JaJuMa sparks the blazing glow.
Magento thrives, Hyvä flies,
Performance soaring, reaching the skies.
Pages stored, restored with grace,
No lag, no wait—a seamless pace.”

 

Even when using a modern, performance-focused Magento frontend like Hyvä Theme and having already top Core Web Vitals on first load / lab data, there is still room for improvement for real users on the site and for Core Web Vitals Field Data.

 

Imagine instantly snapping back to a previously viewed page without any reload delay.
That's the power of the bfcache (Back/Forward Cache), a browser feature that can dramatically improve your Magento 2 store's performance and user experience. But why isn't this powerful feature enabled by default in Magento, and how can you unlock its benefits?
As Magento performance optimization experts, JaJuMa is here to explain.

 

What is Back/Forward Cache (bfcache)?

Bfcache stands for "back-forward cache", and it's a browser optimization feature that stores a complete snapshot of a webpage, including its memory state and the full JavaScript heap, when a user navigates away from it. When the user returns to the page using the back or forward button, the browser can instantly restore the page from this in-memory snapshot instead of requesting it again from the server.

 

Think of it like pausing a video and then resuming it – the content is immediately available exactly where you left off. Restored from bfcache without any network request and even without reading from disk! This results in near-instant page load times for back/forward navigations and a significantly smoother browsing experience for users. This is fundamentally different and faster than the standard browser HTTP cache, which only stores individual file responses (like images or CSS) and still requires the browser to reconstruct the page.

 

awesomeicons6/solid/lightbulb
"The Back/Forward Cache (bfcache) is one of the most powerful tools available for improving a page's performance for real users."
(Source: Lighthouse v10 release blog post)

For a deeper dive into the technical workings of bfcache, the web.dev article on bfcache is an excellent resource.

The Magento Challenge: Why Doesn't Magento Use Bfcache Natively?

Given its benefits, why isn't bfcache automatically enabled on Magento 2 stores?
The primary reason lies in the dynamic nature of e-commerce platforms and potential technical blockers that prevent browsers from safely caching pages. Certain Magento functionalities, like dynamic blocks (e.g., mini-cart updates), session management, or specific JavaScript interactions common in themes and extensions, can inadvertently prevent pages from being eligible for bfcache.
Browsers are cautious and won't cache pages if there's a risk of showing stale or incorrect information, especially in sensitive areas like checkout or customer accounts. Improperly enabling bfcache without considering these dynamic elements can lead to significant issues, such as displaying outdated cart contents or even showing one user's private information to another.

 

Furthermore, some common web development practices, if not carefully managed, can block bfcache eligibility:

  • unload Event Listeners:


    The presence of JavaScript unload event listeners is a major blocker for bfcache in most browsers. This event is unreliable and its use is strongly discouraged; the pagehide event should be used instead. Unfortunately, legacy code or third-party modules in Magento might still use unload.
  • Cache-Control: no-store Header:


    This HTTP header explicitly tells the browser not to store the page in any cache, including bfcache. Magento often sends this header on pages with potentially sensitive or dynamic content (like checkout or account pages) to prevent issues, but sometimes applies it too broadly.
    While Chrome is experimenting with allowing no-store pages into bfcache under specific conditions , Magento's frequent use of Set-Cookie headers in HTML responses often makes stores ineligible for this relaxation, meaning no-store remains a significant blocker in the Magento context.
  • Open Connections:


    Active WebSocket or WebRTC connections can prevent bfcache, as can certain in-progress fetch() or XMLHttpRequest requests or open IndexedDB connections. These might be used by real-time features or certain extensions.
  • window.opener References:


    Pages opened using target="_blank" without rel="noopener" can create a reference that blocks bfcache. Modern browsers often add noopener by default, but older code or specific implementations might still cause issues.

 

Navigating these complexities requires specific adjustments to make Magento pages bfcache-compatible safely and effectively.

awesomeicons6/solid/lightbulb
Community Insight & Warning:
You might see suggestions online (in forums, chats, or social media) to simply remove the Cache-Control: no-store header across your Magento site to enable bfcache. Please be extremely cautious with this advice! It is NOT recommended.
While no-store does block bfcache, blindly removing it without understanding the underlying reasons it was set (often for security or data freshness on dynamic pages like cart/checkout) can lead to serious issues, including showing stale or private user data.
A robust solution requires more nuance than just removing a header. It involves carefully managing page eligibility and ensuring dynamic content is handled correctly upon restoration. Using a well-researched, tested, and proven extension designed specifically for Magento 2 is the recommended approach to avoid these pitfalls.

The Powerful Benefits Of Using bfcache In Magento

Successfully implementing bfcache in a Magento store (typically via a specialized extension) can provide several significant benefits, including:

  1. Dramatically Improved Page Load Times:
    Instant Back/Forward Navigation!
    Back and forward navigations become virtually instantaneous. Pages are restored from the browser's memory, eliminating network requests and server processing time for these actions. Considering that 1 in 10 navigations on desktop and 1 in 5 on mobile are back/forward actions, the cumulative time saving for users is substantial.
  2. Smoother, More Fluid Browsing Experience:
    Eliminating the jarring full-page reloads during back/forward navigation creates a much more seamless and responsive feel for your store.
    This reduces user frustration, encourages exploration, and can positively impact conversion rates.
    This is especially noticeable during product discovery and comparison.
  3. Boosted Core Web Vitals (CWV) scores:
    Bfcache directly improves key CWV metrics that Google uses to measure user experience and influence search rankings. We'll explore this in more detail below, but studies and real-world data suggest enabling bfcache can improve CWV field data by up to 8-10% or even more.
  4. Reduced Server Load:
    Since pages restored from bfcache don't hit your server, enabling it can noticeably decrease server resource consumption, potentially lowering hosting costs and improving site stability during peak traffic.

How Bfcache Supercharges Your Magento Store's Core Web Vitals

Core Web Vitals (LCP, INP, CLS) are critical for SEO and user experience.
Bfcache provides a significant boost, particularly for Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS):

  • Largest Contentful Paint (LCP):
    LCP measures how quickly the main content of a page becomes visible. For pages restored from bfcache, the LCP is near-zero because the page is already rendered in memory. This drastically improves the LCP score for a significant portion of page navigations.
  • Cumulative Layout Shift (CLS):
    CLS measures visual stability during page load. Because bfcache restores a fully rendered snapshot, it entirely eliminates layout shifts during the restoration process. This means pages loaded from bfcache have a CLS score of 0 for that navigation, significantly improving your site's overall CLS field data. As the Chrome Developer Relations Team highlighted, bfcache's introduction led to the single biggest improvement in CLS across the web in 2022.
  • Faster than HTTP Cache: It's important to reiterate that bfcache restores are faster than loading from the standard browser HTTP cache, as bfcache avoids network requests and the need to re-parse and re-render resources.

 

By improving LCP and CLS for a common navigation pattern, bfcache helps Magento stores achieve better CWV scores, leading to improved search rankings and a better user experience.

awesomeicons6/solid/lightbulb
"The bfcache is a significant browser-level performance optimization, and it entirely eliminates the layout shifts during page load, which for many sites is where most of their CLS occurs. The introduction of the bfcache caused the biggest improvement in CLS that we saw in 2022."
Source: Top Core Web Vitals recommendations for 2023 by Chrome Developer Relations Team)

Introducing the Solution: JaJuMa Back/Forward Cache Extension for Magento 2

Overcoming Magento's inherent complexities to safely enable bfcache requires a dedicated solution. The JaJuMa Back/Forward Cache (Bfcache) for Magento 2 is expertly designed to unlock the full potential of bfcache for your store.

Our extension intelligently handles the challenges, ensuring:

  • Reliable Bfcache Enablement:
    Makes your Magento 2 pages eligible for bfcache where appropriate.
  • Safety First:
    Automatically excludes pages that should not be cached (like cart, checkout, customer account areas) to prevent stale data issues.
    It also includes logic to update dynamic elements like the minicart upon user interaction after a restore, balancing performance with data accuracy.
  • Wide Compatibility:
    Works seamlessly with standard Magento 2, is fully compatible with Hyvä Themes, and supports Mage-OS. It also features improved Varnish compatibility.
  • Handles Stale Content:
    Includes specific improvements to better manage potentially stale content when restoring from bfcache.
  • Developer Friendly:
    Features a unique Debug Tool that displays bfcache status and performance KPIs directly in the frontend for logged-in admins, simplifying testing and troubleshooting – a feature not commonly found in competitor solutions.

Don't let Magento's limitations hold back your store's performance. Implement bfcache the right way with JaJuMa.

Bfcache vs. Other Magento Caching: Understanding the Difference

It's important to understand that bfcache complements, rather than replaces, other caching mechanisms commonly used in Magento:

 

Feature/Mechanism Type What it Caches Primary Benefit How JaJuMa Bfcache Complements It
Bfcache (via Extension) Browser (In-Memory) Full page snapshot (HTML, CSS, JS state) Instant back/forward navigation, Improved CWV (LCP/CLS) Optimizes navigation speed after initial load, reduces server load on back/forward clicks.
Magento FPC / Varnish Server-Side Full HTML page output Faster initial page load times (TTFB), Reduced server load Works on initial load; Bfcache handles subsequent back/forward loads.
Redis / Memcached Server-Side (Key-Value) PHP Objects, Session Data, Config Cache Faster data retrieval, Reduced database load Speeds backend operations; Bfcache speeds frontend navigation.
Browser HTTP Cache Browser (Disk/Memory) Static assets (Images, CSS, JS files) Faster loading of assets on repeat visits Caches individual resources; Bfcache caches the entire rendered state of pages the user visited.
Document / HTML Faster "near Zero-TTFB" loading of pages, Improved CWV (LCP/CLS) Caches full HTML/Documents.
Ideally preloaded before user visited/clicked an URL via Page Preload.
BfCache caches after the user visited a page
Browser per document Cache Browser (In-Memory) Full (rendered) page Near instant page views with Zero-TTFB, Improved CWV (LCP/CLS) Caches fully pefetched/prerendered pages before user visited an URL via Speculation Rules API
BfCache caches after the user visited a page

 

In essence, bfcache provides the fastest possible experience for back/forward navigation by serving a complete page directly from memory, while other caches optimize the initial loading or backend processing.
They work together to create a fast overall experience.

Why Every Magento Store Should Use bfcache

Every Magento store should use bfcache because it dramatically improves page load times, user experience, and Core Web Vitals scores for a common navigation pattern. With the increasing importance of search engine ranking and user experience, using bfcache is a simple, yet highly effective way to improve the performance of a Magento store. It is definitely an opportunity for optimization that no Magento store would want to miss.

 

With the many benefits of using bfcache, every Magento store should consider implementing this optimization. Especially since the costs for implementing this must have improvement are very low thanks to the JaJuMa Back/Forward Cache (Bfcache) for Magento 2 extension for Magento 2 – a true "no-brainer" performance win.

 

awesomeicons6/solid/lightbulb
TIP: Meet The
"Instant Page Load Dream Team":

Combine
Back/Forward Cache (bfcache)
+ Page Preload
+ Smart Speculation Rules
to give your site a truly powerful speed and user experience boost!
Use Real User Monitoring (RUM)
to measure and visualize the performance improvement.

Success Stories: Boosting Magento Performance with Bfcache

Check our case-studies/showcases below to see our back/forward cache extension for top LCP values in action.
A Largest Contentful Paint of 0.8s for both, a newly launched store as well as a migration from Luma to Hyvä, is impressive, isn't it?

 

Back/Forward Cache Showcase:
Major Performance Gains for Flowers Retailer with Hyvä

Challenge: Project rescue Luma to Hyvä migration - achieving outstanding CWV and Performance using Back/Forward Cache (bfcache).

60 Days On Hyvä: From Project Rescue, Accelerated To Light Speed & Success

Solution: Implemented JaJuMa's suite of performance optimization extensions, incl. Back/Forward Cache for Magento 2 and custom performance optimization development services.

Results:
  • CLS
    -100% 0.0
  • LCP
    -50% 0.8
  • FCP
    -46% 0.7
  • TTFB
    -55% 0.4
Read the Full Accelerated to Success Story

Back/Forward Cache Showcase:
Quick Hyvä Magento Launch for Weihnachtsstollen.de

Challenge: Launching a high-performance Magento store with in record time. On a budget, without compromising, but going "beyond 'only green' Core Web Vitals," with advanced optimizations incl. Back/Forward Cache.

A Delicious Ecommerce Recipe: Baking A Super Fast Magento Store in Weeks (with Hyvä & JaJuMa)

Solution: Leveraged JaJuMa's ready-to-use performance optimization extensions, incl. Back/Forward Cache for Magento 2 and custom performance optimization development services.

Results:
  • CLS
    0
  • LCP
    0.8s
  • FCP
    0.7s
  • TTFB
    0.4s
Learn How To Bake A Super Fast Hyvä Store in Weeks

Testing Your Magento Store's Bfcache Eligibility

Want to see if your pages are currently being served from bfcache?
You can easily test this using your browser's developer tools:

 

  • Using Chrome DevTools:

    1. Open Chrome DevTools on the page you want to test (Right-click -> Inspect).
    2. Navigate to the Application tab.
    3. In the left-hand panel, scroll down to the Cache section and click on Back/forward cache.
    4. Click the Test back/forward cache button.
    5. Chrome will attempt to navigate away and back. The results panel will show whether the page was successfully restored from bfcache or list the reasons why it wasn't.
  • Using Google Lighthouse:

    • Recent versions of Google Lighthouse also include an audit that checks for bfcache eligibility and identifies blockers. Running a Lighthouse report on your pages can provide valuable insights.
  • Advanced Debugging:

 

If your tests show pages are "Not Actionable" or list specific blockers, it indicates an opportunity for optimization, potentially using the JaJuMa Bfcache Extension.

Conclusion: Don't Miss Out on the Bfcache Advantage

Implementing bfcache in a Magento store provides several significant & measuable benefits, including improved page load times for back/forward navigation, a smoother browsing experience, and improved Core Web Vitals scores. While the exact improvement in performance and Core Web Vitals scores will vary depending on the website's specific design and content, studies and real-world data have shown that using bfcache can improve performance KPIs and user experience dramatically.
The benefits of using the bfcache were not only confirmed by Google, but others even name it a "Performance Game Changer".

 

Instant back/forward navigation is no longer just a 'nice-to-have' – it's a key component of a modern, high-performing e-commerce site.

 

While Magento's dynamic nature presents challenges to native bfcache support, these hurdles can be safely and effectively overcome.
Ignoring bfcache means leaving significant performance gains on the table.

It's important to note that while bfcache can be a powerful optimization tool, it's not a one-size-fits-all solution without careful implementation. Depending on the website's design and functionality, native Magento setups often prevent bfcache eligibility.
Furthermore, implementing it incorrectly carries risks, such as displaying stale or private user data.

 

The JaJuMa Back/Forward Cache (Bfcache) for Magento 2 provides a robust, reliable, and expertly developed solution specifically for Magento 2.
It addresses the common blockers, ensures compatibility with modern setups like Hyvä and Mage-OS, and even includes a unique Debug Tool to aid developers.

Ready to provide your customers with lightning-fast navigation and boost your store's performance metrics?