Architecting Magento 2 Full Page Cache: Design, Boundaries, and Operational Checks
Learn how to size Magento 2 Full Page Cache, separate public and private content, verify hits/misses, and avoid stampedes or stale data.
30 Jul 2026, 01:40 UTC

The Problem: Rendering Overhead at Scale
Magento 2 renders pages by executing layout XML, blocks, and database queries. Without caching, each request repeats this work, causing CPU spikes and high Time to First Byte (TTFB) under load.
Smallest Suitable Design: Redis vs. Varnish
For many stores the choice is between Magento’s built‑in cache (Redis) and an external reverse proxy (Varnish). The "smallest suitable design" depends on traffic volume and infrastructure constraints.
Option A: Redis (Built‑in Cache)
Redis stores the rendered HTML in memory. Magento still receives the request, checks the cache, and returns the HTML if present. This adds only one network hop to the Redis server.
Option B: Varnish (External Cache)
Varnish sits in front of the web server (nginx/apache). On a cache hit it serves the HTML without invoking PHP, reducing TTFB and CPU usage.
| Metric | Redis (Built‑in) | Varnish (External) |
|---|---|---|
| Request Path | Client → Web Server → PHP → Redis | Client → Varnish → (optional) Web Server |
| TTFB on Hit | Low (~1-5 ms) | Ultra-Low (~0-1 ms) |
| CPU Load | Moderate (PHP boots on each request) | Minimal (PHP bypassed on hit) |
| Operational Complexity | Low (configured via env.php) | Moderate (requires VCL and service management) |
Trust and Data Boundaries
Full Page Cache stores a static HTML snapshot. If that HTML contains user‑specific data (e.g., customer name, cart contents) it would be leaked to every subsequent visitor.
Hole‑Punching with Private Content
Magento splits the page into Public Content (cacheable) and Private Content (user‑specific). The cached template contains placeholders that are replaced by JavaScript after load.
- Public Content: HTML fragment stored in Redis/Varnish, safe for all users.
- Private Content: JSON data kept in browser storage, fetched via
/customer/section/load.
Operational Checks and Verification
Verify that requests are served from cache and that invalidation works as expected.
Header Verification
Enable debug headers (X-Magento-Cache-Debug) in developer mode or inspect the Age header.
curl -I https://example.com/product-page.html
Look for X-Magento-Cache-Debug: HIT or a non‑zero Age value indicating a cached response.
Backend Monitoring
If using Redis, run MONITOR to see key accesses. Use only on staging or low‑traffic periods.
redis-cli MONITOR
For Varnish, check varnishlog for Hit or Miss tags.
Failure Modes
Common issues are cache stampedes and stale content due to overly aggressive invalidation.
Cache Stampede
When a popular page expires, many concurrent requests find a miss and try to regenerate the page simultaneously, overloading the database.
Mitigation: use a cache warming script or increase the TTL for high‑traffic pages.
Invalidation Loops
Magento invalidates pages by cache tags (e.g., product price update). If an automated process updates prices every minute, the cache is cleared faster than it can be filled, rendering FPC ineffective.
Mitigation: batch updates, use a longer invalidation interval, or exclude frequently changed data from full‑page caching.
Conditions That Would Change the Design
Re‑evaluate the architecture when any of the following are observed:
- TTFB on cached pages consistently exceeds 500 ms.
- PHP‑FPM workers remain saturated despite a high cache hit ratio.
- Personalization requirements grow to the point where hole‑punching causes noticeable layout shifts (CLS) that affect SEO.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.