Magento / Adobe Commerce
Last reviewed: 2026-10-27 · Applies to: Magento Open Source / Adobe Commerce 2.4.x; Varnish (on-prem), Fastly (Adobe Commerce Cloud), Valkey/Redis
Contents
- When to read this
- How to detect
- Default recipe
- Rules and gotchas
- Cache types
- Version notes
- Verify
- Sources
When to read this
When the store is Magento or Adobe Commerce. Magento has full-page cache with tag-based purge built in; production must use Varnish or Fastly for the FPC and Valkey/Redis for the backend cache and sessions.
How to detect
composer.json with magento/product-community-edition or magento/product-enterprise-edition; bin/magento; app/etc/env.php (cache backends, http_cache_hosts), app/etc/config.php; .magento.app.yaml/.magento/services.yaml (Adobe Commerce Cloud). Response headers X-Magento-Cache-Debug, X-Magento-Tags (developer mode), X-Cache (Fastly), Fastly-Debug.
Default recipe
- Full-page cache: Varnish on-prem (Stores → Configuration → Advanced → System → Full Page Cache → Varnish), or Fastly on Adobe Commerce Cloud. Generate the VCL from Magento, don't hand-write it.
- Backend cache + sessions: Valkey (2.4.9 and later security patches of 2.4.5–2.4.8 support it) or Redis; separate databases/instances for cache, page cache (if not Varnish) and sessions.
- Purge: Magento sends
PURGEwithX-Magento-Tags-Patterntohttp_cache_hostson entity save; keep that path working and authenticated. - Private content (cart, customer name, wishlist) loads via customer-data sections (
customer/section/load), never via FPC.
bin/magento config:set system/full_page_cache/caching_application 2 # 2 = Varnish
bin/magento varnish:vcl:generate --export-version=7 --output-file=default.vcl
bin/magento setup:config:set --http-cache-hosts=varnish:6081
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=valkey --cache-backend-redis-db=0
bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=valkey --page-cache-redis-db=1 # only if not Varnish
bin/magento setup:config:set --session-save=redis --session-save-redis-host=valkey --session-save-redis-db=2
bin/magento cache:status
bin/magento cache:clean full_page # by type; prefer clean over flushRules and gotchas
- The built-in (file/Redis) FPC is for development; production uses Varnish or Fastly.
- Check the supported Varnish version for your Magento patch release (sources disagree between 7.6 and 8); generate VCL for that version.
cache:flushempties the whole storage (including other apps' keys on shared Redis);cache:cleanremoves only Magento-tagged entries. Prefercleanor tag purges.- Blocks marked
cacheable="false"in layout XML make the whole page uncacheable; use private content sections instead. - Separate Redis/Valkey databases for cache vs sessions; cache eviction policies must not evict sessions.
- Varnish purge requests must be restricted to the Magento hosts (ACL in VCL).
- Reindex and cache warming after large catalog imports; the FPC is cold after a full purge.
Cache types
| Type | Purpose |
|---|---|
config, layout, block_html, collections, reflection, db_ddl, eav, customer_notification, config_integration, config_webservice, translate, compiled_config, graphql_query_resolver_result |
Backend caches (Valkey/Redis) |
full_page |
Page cache (Varnish/Fastly in production) |
Version notes
- Valkey replaces Redis in 2.4.9 and later patches of 2.4.5–2.4.8.
- Varnish 4/6 VCL exports for older 2.x releases.
- File-system cache backend in production.
Verify
curl -s -o /dev/null -D - https://store.example.com/ | grep -iE 'x-magento-cache-debug|x-cache|age|cache-control'
bin/magento cache:status