Magento 2 Cacheable False: When to Use and When Not To

Magento 2 Cacheable False: When to Use and When Not To

[Updated: February 26, 2026]

One cacheable="false" attribute in your layout XML can disable Full Page Cache for an entire page. That turns a sub-100ms cached response into a 300-2000ms server render on every request.

This guide covers when cacheable false is the right call, when to avoid it, and what alternatives keep your store fast.

TL;DR

Magento 2 cacheable false = a layout XML attribute that excludes a block from Full Page Cache. The block renders fresh on every request. One uncacheable block disables FPC for the entire page.

Perfect for: Mini cart blocks, customer welcome messages, session-sensitive data, real-time pricing or stock counters.

Not ideal for: Containers, phtml templates, PHP block classes, UI Components, or any non-block element. Use Private Content or AJAX instead.

What is Magento 2 Cacheable False?

Magento 2 uses Full Page Cache (FPC) to store entire HTML pages and serve them without running PHP on each request. This is the single biggest performance optimization for any Magento store.

The cacheable="false" attribute tells Magento to skip FPC for a specific block. That block renders fresh on every page load. The catch: if any block on a page has cacheable="false", Magento disables FPC for the entire page.

This attribute is essential for personalized elements like mini carts or customer greetings. Overusing it increases server load and bypasses the performance gains from managed Magento hosting infrastructure. Use it only when no alternative exists.

Critical rule: Setting cacheable="false" in default.xml (the base layout handle applied to every page) disables FPC across your entire store. This is the most severe misuse case. Always scope uncacheable blocks to specific page handles.

The cacheable="false" mechanism has not changed in Magento 2.4.7 or 2.4.8. The behavior is identical across all 2.4.x versions. Adobe Commerce 2.4.8 (April 2025) added Valkey 8.x support as an alternative to Redis for backend cache storage, but the FPC evaluation logic remains the same. Valkey improves performance and stability for backend cache operations. It does not change how Magento evaluates cacheable="false" on layout blocks.

When to Use Cacheable False in Magento 2

On <block> Elements

On block elements

Add cacheable="false" when defining a block that renders dynamic or user-specific content:

<block class="Magento\Framework\View\Element\Template"
       name="my.dynamic.block"
       template="Vendor_Module::dynamic.phtml"
       cacheable="false"/>

Common examples:

  • Mini cart block
  • Customer welcome message block
  • Live pricing block
  • Recently viewed items

This instructs Magento not to cache the block's output in FPC.

On <referenceBlock> Elements

Use cacheable="false" to mark an existing block as uncacheable:

<referenceBlock name="header.links" cacheable="false"/>

Magento re-renders the header.links block on each request. This is useful for blocks that display login/logout links personalized for each user.

When NOT to Use Cacheable False

On <container> Elements

Containers are structural placeholders in Magento's layout system. They organize blocks and define page structure (header, footer, main content area). Containers do not generate HTML output.

Setting cacheable="false" on a container has no effect. Magento ignores it. Apply the attribute to individual blocks inside the container instead.

In .phtml Template Files

Template files handle HTML rendering only. They do not control caching behavior. Declaring cacheable="false" inside a .phtml file does nothing.

If you need a block to bypass cache, declare cacheable="false" in the layout XML file, not in the template.

In PHP Block Classes

Block classes handle business logic and data for templates. Magento does not provide a setCacheable(false) method or equivalent. You cannot mark a block as uncacheable through PHP code. Use the XML layout file.

In UI Components XML

In UI Components XML

Magento UI Components use a different rendering system based on JavaScript components and Knockout.js bindings. They do not respect cacheable="false" from layout XML.

For dynamic behavior in UI Components, use AJAX, Knockout observables, or component-specific caching settings.

On Checkout Blocks

Magento 2 excludes checkout pages from FPC by default. Adding cacheable="false" to any block on checkout_index_index or checkout_cart_index is redundant. The page renders fresh on every request regardless. This is one of the most common unnecessary uses of the attribute.

On Non-Block Elements

The following layout instructions do not support cacheable="false":

  • <referenceContainer>
  • <move>
  • <remove>

These are structural instructions with no caching behavior.

Why Use Cacheable False?

1. To Serve User-Specific or Session-Sensitive Data

FPC caches the entire HTML page and serves it to all visitors. If a block renders data based on the current customer session, you cannot cache it without leaking data between users.

Examples:

  • Mini cart item count
  • "Welcome, John" greeting
  • Login/logout/account links
  • Wishlist or recently viewed products

The attribute forces Magento to regenerate the block's output on each request. This ensures personalized content is accurate and prevents data leakage between sessions. Magento identifies the current user through session cookies, and any block that reads cookie or session data must bypass cache.

2. To Avoid Serving Outdated Real-Time Data

FPC stores a snapshot of the page at the time of the first load. Unless invalidated, the cached version stays unchanged. If a block displays fast-changing information, the cached content becomes stale.

Use cases:

  • Flash sale countdowns
  • Live pricing based on active promotions
  • "Only 2 items left in stock" messages

The attribute ensures these elements reflect the current backend state.

3. To Simplify Caching Logic for Custom Blocks

Magento uses cache keys, cache tags, and lifetimes to manage block caching. Building a custom block with proper caching requires generating unique cache keys, attaching invalidation tags, and managing expiry times.

Setting cacheable="false" removes that complexity. The block always reflects the latest data. This is useful for quick prototypes, custom extensions, or low-traffic admin-facing widgets where caching functionality adds more overhead than value.

4. To Prevent Cache Contamination

To Prevent Performance Bugs or Cache Contamination

Including dynamic logic inside a block that is cached by default can cause:

  • Visual glitches (User A's cart showing for User B)
  • JavaScript errors from outdated DOM elements
  • Incorrect content across user sessions

The attribute prevents these bugs by ensuring fresh output per request instead of serving from a shared cache.

5. To Maintain Customer Trust

Cached data can mislead customers:

  • A mini cart showing 2 items when the cart is empty
  • A stock warning showing "Only 1 left" after the product sold out
  • A loyalty badge that does not reflect the actual customer profile

Accurate UI elements maintain trust and reduce support tickets.

6 Common Challenges and Solutions

1. Performance Degradation

Using cacheable="false" forces Magento to re-render the block on every request. Overusing it can increase server CPU load, slow down page load time, and negate Full Page Cache benefits.

Solution:

  • Use the attribute only for mini cart, customer greetings, or session-sensitive blocks
  • For heavier dynamic content, load it via AJAX after the cached page renders
  • Consider Magento's Private Content framework (see alternatives below)

2. Identifying Which Block Broke FPC

Setting cacheable="false" on one block excludes the entire page from FPC. Finding the offending block is not always obvious.

Solution:

  • Enable developer mode
  • Check the X-Magento-Cache-Debug header in your browser dev tools (HIT = cached, MISS = not cached)
  • Use Magento\Framework\App\Response\Http\Interceptor to inspect caching behavior
  • Test by removing blocks one at a time or logging with a custom plugin
  • Adobe Commerce 2.4.1+ users can use the Site-Wide Analysis Tool (SWAT) to detect layout files containing cacheable="false" across the entire codebase

3. Cacheable False Not Having Any Effect

A block still appears cached after adding the attribute.

Common causes:

  • The block sits inside a cached parent block
  • CMS pages cache at a higher level
  • You tested without clearing the cache first

Solution:

4. Increased Time to First Byte (TTFB)

Increased Time to First Byte

Uncached blocks increase server-side page generation time. High-traffic stores feel this impact most.

Solution:

  • Measure impact with monitoring tools like New Relic or a built-in profiler
  • Offload dynamic blocks to frontend JavaScript when possible
  • Optimize the block's logic: reduce database queries and avoid heavy loops
  • Consider managed hosting with auto scaling to handle the increased server load

5. Caching Logic Conflicts

Mixing block-level caching with layout-level cacheable="false" can cause inconsistent behavior, especial if you override cache logic in PHP.

Solution:

  • Manage caching behavior through XML layout files, not PHP overrides
  • If using PHP overrides, avoid conflicting with layout XML declarations
  • Document your cache logic so the team understands the setup

6. Unintended Global Cache Disablement

A single uncacheable block in the layout disables FPC for every page that includes it.

Example: You add cacheable="false" to a header block. Every page on the site now skips FPC.

Solution:

  • Isolate uncacheable blocks to specific pages (checkout, account dashboard)
  • Use AJAX to render user-specific content on otherwise cacheable pages
  • Load personalized blocks after page load to reduce impact
  • Check for FPC invalidation issues if cache behavior seems unpredictable

3 Better Alternatives to Cacheable False

1. Private Content (Sections)

Private Content is Magento's built-in framework for loading customer-specific data via JavaScript after the page has loaded from cache. This covers mini carts, welcome messages, and other personalized elements.

How it works:

  1. Magento serves the cached page (fast, from FPC)
  2. JavaScript (customer-data.js) fetches user-specific data from /customer/section/load/ via AJAX
  3. Knockout.js updates the DOM with personalized content

Implementation: Define which actions invalidate which sections in sections.xml:

<config>
    <action name="checkout/cart/add">
        <section name="cart"/>
    </action>
</config>

Advantages:

  • Keeps Full Page Cache intact
  • Personalizes content without server-side overhead
  • Out-of-the-box support for common blocks (mini cart, welcome message)

Private Content is the recommended approach for most personalization use cases. It replaces cacheable="false" for customer greetings, cart data, and wishlist counts.

Note: The older _isScopePrivate PHP property on Block classes is deprecated. Use sections.xml + customer-data.js instead.

2. JavaScript (AJAX) Rendering

JavaScript Rendering

Render dynamic parts of the page via AJAX or frontend JavaScript instead of disabling FPC. Best for live stock updates, flash sale timers, or third-party data.

Workflow:

  1. Serve the cached page without the dynamic block
  2. JavaScript fetches live data from a custom controller
  3. Inject the response into the DOM

Advantages:

  • Granular control over timing and logic
  • Does not impact page caching
  • Good for volatile or third-party data

3. Edge Side Includes (ESI)

ESI is a caching technique supported by Varnish. It allows partial caching of a page where only certain blocks render fresh while the rest loads from cache.

Magento 2 has limited ESI support out of the box via Varnish configuration. Set a ttl attribute (in seconds) on a block in layout XML. Varnish fetches and assembles the block content with its own cache lifetime.

Advantages:

  • Mix cached and uncached blocks on the same page
  • Offload dynamic rendering to Varnish or a reverse proxy
  • Scales well for high-traffic stores

Limitation: Varnish does not support ESI over HTTPS. Magento's ProcessLayoutRenderElement downgrades https:// to http:// when generating ESI tags. This makes ESI impractical for most modern stores running HTTPS. Evaluate this constraint before adopting ESI in production.

FAQ

What does cacheable false do in Magento 2?

It tells Magento to skip Full Page Cache for a specific block. The block renders fresh on every request. If any block on a page has this attribute, FPC is disabled for the entire page.

Will cacheable false slow down my website?

Yes, if overused. Each uncacheable block forces server-side rendering on every request. Use it only for dynamic or personalized content. For other cases, use Private Content or AJAX loading.

Can I make part of a page non-cacheable without affecting the whole page?

Not with cacheable="false". One uncacheable block disables FPC for the entire page. To isolate dynamic content, use Private Content sections or AJAX. These methods update specific parts without breaking page caching.

What is the difference between cacheable false and Private Content?

Cacheable false disables server-side caching for a block and the entire page. Private Content loads user-specific data via JavaScript after the cached page has loaded. Private Content is the better choice for personalization because it keeps FPC active.

How do I debug cacheable false issues?

Enable developer mode. Open browser dev tools and check the X-Magento-Cache-Debug response header. HIT means the page loads from cache. MISS means FPC is bypassed. Remove blocks one at a time to identify which one causes the cache miss.

Can I use cacheable false on a CMS page?

Yes, but with caution. CMS pages are cached by default. Adding a block with cacheable="false" via layout XML will disable FPC for that CMS page. Use AJAX loading for dynamic elements on CMS pages to keep them cacheable.

Does cacheable false work with Varnish?

When Varnish serves as the FPC backend, cacheable="false" prevents the page from being stored in the Varnish cache. The request passes through to PHP on every load. ESI (Edge Side Includes) offers a better approach for mixing cached and uncached content with Varnish.

What is the performance impact of cacheable false on high-traffic stores?

Each page that bypasses FPC requires a full PHP render. On a store handling 1,000+ concurrent users, this means 1,000+ PHP processes instead of cached responses. TTFB increases, server load spikes, and response times degrade. Use managed hosting with auto scaling to handle the load, and minimize uncacheable blocks.

How do I find all cacheable false blocks in my Magento store?

Search your codebase for cacheable="false" across all layout XML files. Run grep -r 'cacheable="false"' app/design/ vendor/ from your Magento root. Review each match and evaluate whether Private Content or AJAX could replace it.

Should I use cacheable false for custom checkout blocks?

Checkout pages are excluded from FPC by default in Magento 2. Adding cacheable="false" on checkout blocks is redundant. The checkout page renders fresh on every request regardless of the attribute.

Conclusion

Magento 2 cacheable="false" is a powerful but dangerous attribute. One misplaced instance can disable Full Page Cache across your entire store. This applies to both Magento Open Source and Adobe Commerce (all 2.4.x versions).

Use it for session-sensitive blocks like mini carts and customer greetings. Avoid it everywhere else. For most dynamic content, Private Content sections and AJAX loading offer better solutions that keep FPC active.

Third-party extensions are the most common source of unexpected cacheable="false" declarations. In most cases where an entire store loses FPC, a marketing, popup, personalization, or review module is the cause. Run grep -r 'cacheable="false"' app/code/ vendor/ after every extension installation. Remove or replace any uncacheable block that does not handle session data.

For stores running Magento 2.4.x with Valkey or Redis L2 cache, the use_stale_cache option can serve slightly outdated cached content while fresh data generates in the background. This does not replace cacheable="false" but reduces the impact of cache misses on response times.

Headless and GraphQL-based stores (PWA Studio, Next.js, Vue Storefront) handle caching at a different layer. cacheable="false" has no effect in headless setups because FPC does not apply to API responses. These architectures rely on API response caching, persisted queries, and client-side logic for personalization.

Fast page delivery starts with proper caching strategy and reliable infrastructure. Choose managed Magento hosting on AWS to handle both cached and uncached workloads with auto scaling.

CEO & Co-Founder

Raphael Thiel co-founded MGT-Commerce in 2011 together with Stefan Wieczorek and has built it into a leading Magento hosting provider serving 5,000+ customers on AWS. With 25+ years in e-commerce and cloud infrastructure, he oversees hosting architecture for enterprise clients. He also co-founded CloudPanel, an open-source server management platform.


Get the fastest Magento Hosting! Get Started