Magento 2 Cache Management: Types, Commands & Best Practices
[Updated: March 19, 2026]
A slow Magento store loses customers with every extra second of load time. Proper cache management is the first line of defense against sluggish performance.
This guide covers all 17 Magento 2 cache types, complete CLI commands, Redis and Varnish configuration, and proven best practices that keep your store fast under load.
Key Takeaways
-
Magento 2 includes 17 built-in cache types that store configuration, layout, HTML, and full pages to reduce server processing.
-
Use
cache:cleanfor targeted cleanup andcache:flushfor complete storage reset. -
Redis handles object and session caching, while Varnish serves full pages without hitting PHP.
-
Production mode requires CLI commands for cache type changes. Developer mode allows admin panel toggling.
-
Schedule cache operations during off-peak hours. A full flush under load can bring your store down.
What Is Magento 2 Cache Management?
Magento 2 cache management = the system that stores processed data in temporary storage so your server doesn't rebuild every page from scratch. Faster pages, lower server load, better conversions.
Perfect for: Store owners optimizing performance, DevOps teams managing production servers, agencies maintaining client stores
Not ideal for: Stores in active development where cache would hide code changes
Magento 2 processes hundreds of database queries, XML configurations, and template renderings for a single page load. Without caching, every visitor request triggers this full processing cycle.
Cache management stores the results of these operations in fast-access storage. When the next visitor requests the same page, Magento serves the cached version instead of rebuilding it. This cuts page load times from seconds to milliseconds.
The impact is measurable. Cached pages deliver Time to First Byte (TTFB) under 200ms. Uncached pages on the same server can take 2 to 5 seconds. A 1-second delay in page load reduces conversions by up to 7% (based on industry research by Aberdeen Group and Akamai).
All 17 Magento 2 Cache Types
Magento 2.4.8 includes 17 distinct cache types. Each stores a different category of processed data.
| Cache Type | Identifier | Tag | What It Stores |
|---|---|---|---|
| Configuration | config |
CONFIG |
Merged XML configuration from all modules |
| Layouts | layout |
LAYOUT_GENERAL_CACHE_TAG |
Compiled page layout instructions |
| Block HTML Output | block_html |
BLOCK_HTML |
Rendered HTML fragments per block |
| Collections Data | collections |
COLLECTION_DATA |
Database query results for collections |
| Reflection Data | reflection |
REFLECTION |
API interface reflection data |
| Database DDL | db_ddl |
DB_DDL |
Database schema definitions |
| Compiled Config | compiled_config |
COMPILED_CONFIG |
Pre-compiled configuration data |
| EAV Types | eav |
EAV |
Entity attribute value type metadata |
| Customer Notification | customer_notification |
CUSTOMER_NOTIFICATION |
Customer notification data |
| GraphQL Query Results | graphql_query_resolver_result |
GRAPHQL_QUERY_RESOLVER_RESULT |
Cached GraphQL resolver responses |
| Integrations Config | config_integration |
CONFIG_INTEGRATION |
Integration configurations |
| Integrations API Config | config_integration_api |
CONFIG_INTEGRATION_API |
API integration configurations |
| Admin UI SDK | admin_ui_sdk |
ADMIN_UI_SDK |
Admin UI SDK configuration data |
| Full Page Cache | full_page |
FPC |
Complete rendered HTML pages |
| Target Rules | target_rule |
TARGET_RULE |
Product target rule index (Commerce only) |
| Web Services Config | config_webservice |
CONFIG_WEBSERVICE |
Web API structure cache |
| Translations | translate |
TRANSLATE |
Translation merge data from all modules |
The full_page cache delivers the largest performance gain. It serves complete pages without executing PHP code or querying the database.
Cache Management via Admin Panel
Access cache management through System > Tools > Cache Management in the Magento Admin.
The Cache Management page shows the status of each cache type (enabled or disabled) along with its associated tag. Two buttons in the upper right corner control bulk operations:
Flush Magento Cache removes all items tagged as Magento cache. This affects only Commerce-specific data.
Flush Cache Storage clears the entire cache storage, including data from other applications sharing the same backend. Use this with caution on shared Redis instances.
Additional controls at the bottom of the page handle specific cache categories:
- Flush Catalog Images Cache removes pre-generated product image resizes
- Flush JavaScript/CSS Cache clears merged and minified static files
Role-Based Access Control
Adobe recommends restricting cache flush permissions to administrator roles. Giving broad access to cache management can degrade storefront performance if caches are flushed during peak traffic.
Configure role-specific access under System > Permissions > User Roles. Cache-related resources include flush operations, cache type toggling, and catalog image or static file purging.
CLI Commands for Cache Management
Production mode in Magento 2.4.8 restricts admin panel cache toggling. All cache type changes must happen through the command line interface.
View cache status:
bin/magento cache:status
Lists all cache types with their enabled or disabled state.
Enable cache types:
bin/magento cache:enable [type] [type] ...
Enabling a cache type cleans it. Omit the type identifier to enable all types at once.
Disable cache types:
bin/magento cache:disable [type] [type] ...
Omit the type to disable all cache types. Useful during development or debugging sessions.
Clean cache (targeted):
bin/magento cache:clean [type] [type] ...
Removes expired and invalidated entries from enabled cache types. This is the safer option for production use.
Flush cache (complete reset):
bin/magento cache:flush [type] [type] ...
Purges the entire cache storage. On a shared Redis instance, this can clear data from non-Magento applications sharing the same backend.
All CLI commands must run as the filesystem owner. Running as root or a different user creates permission issues that prevent cache regeneration.
Clean vs. Flush: When to Use Each
The distinction matters for production stability.
| Operation | What It Does | When to Use | Risk Level |
|---|---|---|---|
cache:clean |
Removes invalidated entries only | After config changes, product updates | Low |
cache:flush |
Purges entire cache storage | After version upgrades, major code changes | Medium |
| Admin "Flush Magento Cache" | Same as cache:clean for all types |
Quick refresh from admin panel | Low |
| Admin "Flush Cache Storage" | Same as cache:flush for all backends |
Full reset when issues persist | High |
Use cache:clean as your default. It targets only stale data and leaves valid cache entries intact. Your store keeps serving cached content for pages that haven't changed.
Reserve cache:flush for situations where clean doesn't resolve the issue: post-upgrade, after module installation, or when cached data becomes corrupted.
For the complete comparison with troubleshooting steps, see the cache clean vs flush guide.
Full-Page Cache: Built-in vs. Varnish
Full-page caching (FPC) delivers the biggest performance improvement. It serves complete HTML pages without invoking PHP or the database.
Magento 2 offers two FPC backends:
Built-in (File-Based)
The default option stores cached pages on disk. Suitable for small stores or development environments.
Configure at Stores > Configuration > Advanced > System > Full Page Cache:
- Set Caching Application to "Built-in Application"
- Set TTL for public content (default: 86400 seconds, which equals 24 hours)
Varnish
Varnish reverse proxy caching sits in front of your web server and serves cached pages from memory. This delivers TTFB under 50ms for cached requests.
Magento 2.4.8 supports Varnish 7.6. Configuration parameters:
- Access list: IP addresses authorized to purge the cache (default: localhost)
- Backend host: Your web server IP address (default: localhost)
- Backend port: The port your web server listens on (default: 8080)
- Grace period: How long Varnish serves stale content while fetching a fresh copy
After configuring these values in the Magento admin, export the generated varnish.vcl file and deploy it to your Varnish server.
Varnish handles three visitor types with different caching strategies:
| Visit Type | Behavior |
|---|---|
| Non-sessioned | Pages cached and shared across all anonymous visitors |
| Sessioned | Separate cache entries per session (cart, comparison lists) |
| Customer | Personalized cache based on customer group and pricing rules |
For production stores with more than 1,000 daily visitors, Varnish is the recommended choice. The performance gap between file-based and Varnish FPC grows with traffic volume.
Redis for Object and Session Cache
Redis replaces the default file-based cache backend with in-memory storage. This eliminates disk I/O bottlenecks that slow down cache reads on busy stores.
Magento 2.4.8 supports Redis 7.2 and Valkey 8 as cache backends.
Redis serves two distinct purposes in Magento:
Object cache: Stores configuration, layout, block HTML, and other cache types in memory. Replaces the default file system storage with sub-millisecond reads.
Session storage: Keeps user sessions in Redis instead of files or the database. This prevents session loss during deployments and supports horizontal scaling across multiple web servers.
Configure Redis by editing app/etc/env.php. Use separate Redis databases for object cache (db 0), full page cache (db 1), and sessions (db 2) to enable independent flushing of each layer.
For the step-by-step setup process, see how to configure Magento 2 with Redis.
Cache Warming Strategies
A cold cache after a flush forces your server to rebuild every page on first request. During high traffic, this creates a thundering herd problem where hundreds of concurrent visitors trigger full page generation at the same time.
Cache warming pre-generates cached pages before real visitors arrive. Three approaches work:
Manual warming: Use curl or wget to crawl your sitemap URLs after a cache flush:
wget --spider --recursive --level=2 https://your-store.com/sitemap.xml
Scheduled warming: Set up a cron job that crawls key pages (homepage, category pages, top products) at regular intervals after each cache clean operation.
Module-based warming: Cache warmer extensions monitor cache invalidation events and rebuild affected pages in the background without manual intervention.
For stores on managed Magento hosting, cache warming is handled at the infrastructure level. The hosting stack keeps Varnish warm through automated health checks and scheduled crawls.
Best Practices for Production Stores
| Practice | Details |
|---|---|
| Flush after extension installation | Clean all cache types after installing or updating any module |
| Flush after version upgrades | Required when upgrading Magento versions or applying security patches |
| Schedule during off-peak hours | A full flush regenerates all cached data, increasing server load. Late night or early morning is safest. |
| No flush needed after reindexing | Reindexing updates search indexes without invalidating cache entries |
| Clear browser cache after changes | Magento cache operations don't affect browser-stored data. Visitors may need a hard refresh. |
| Restrict flush permissions | Limit cache management access to administrator roles only |
| Monitor TTFB after changes | Track Time to First Byte before and after cache operations to verify the performance impact |
Development vs. Production Mode
Magento behaves different with cache depending on the deploy mode:
Developer mode: Cache types can be toggled from both admin panel and CLI. Static files generate on each request. Keep most caches disabled during active development to see code changes in real time.
Production mode: Cache type toggling requires CLI access. Static content must be deployed with bin/magento setup:static-content:deploy before it appears on the frontend. All caches should be enabled for fast store performance.
Pros and Cons of Magento 2 Cache Management
| Pros | Cons |
|---|---|
| Reduces page load from seconds to milliseconds | Invalidated cache can serve stale content |
| Lowers server CPU and database load under traffic | Full flush during peak hours causes temporary slowdown |
| 17 granular cache types for targeted control | Complex configuration for multi-server setups |
| Varnish FPC delivers sub-50ms TTFB | Requires infrastructure expertise to tune |
| Redis enables horizontal scaling across servers | Additional service to monitor and maintain |
FAQ
What are the default cache types in Magento 2.4.8?
Magento 2.4.8 includes 17 cache types: config, layout, block_html, collections, reflection, db_ddl, compiled_config, eav, customer_notification, graphql_query_resolver_result, config_integration, config_integration_api, admin_ui_sdk, full_page, target_rule, config_webservice, and translate. Each stores a different category of processed data to reduce redundant server operations.
How do I check cache status from the command line?
Run bin/magento cache:status from your Magento root directory. This displays all cache types with their current state (enabled or disabled). Run the command as the filesystem owner to avoid permission errors.
What is the difference between cache clean and cache flush?
cache:clean removes only invalidated or expired entries from enabled cache types. cache:flush purges the entire cache storage, including entries from other applications on shared backends. Use clean for routine maintenance and flush for major changes like version upgrades.
Should I use Varnish or the built-in cache?
For production stores with regular traffic, use Varnish. It serves cached pages from memory with TTFB under 50ms, while the built-in file cache adds disk I/O latency. Magento 2.4.8 supports Varnish 7.6. The built-in cache works for development or low-traffic staging environments.
How do I configure Redis as the cache backend?
Edit app/etc/env.php to set the cache backend to Magento\Framework\Cache\Backend\Redis. Specify the Redis server host, port, and database number. Use separate Redis databases for object cache (db 0), full page cache (db 1), and sessions (db 2) to enable independent flushing.
When should I flush the cache?
Flush after installing extensions, upgrading Magento versions, or applying security patches. Also flush when content changes don't appear on the frontend after a clean. Schedule flushes during low-traffic periods to minimize the performance impact of cache regeneration.
Does reindexing require a cache flush?
No. Reindexing updates database indexes for search and catalog operations. It does not invalidate cache entries. Flushing cache after reindexing is unnecessary and adds avoidable server load.
How do I warm the cache after flushing?
Crawl your sitemap URLs using wget or curl to pre-generate cached pages before visitors arrive. Cache warmer extensions can automate this by monitoring invalidation events and rebuilding affected pages in the background. Managed hosting platforms handle cache warming at the infrastructure level.
What causes cache invalidation in Magento 2?
Changes to products, categories, CMS pages, configuration settings, or URL rewrites trigger cache invalidation. Magento marks affected cache entries as invalid and displays a notification in the admin panel. Clean the invalidated cache types to serve fresh data.
How does managed hosting improve cache performance?
Managed Magento hosting providers pre-configure Redis, Varnish, and OpenSearch with settings tuned for Magento workloads. The hosting stack handles cache warming, Varnish VCL generation, Redis memory management, and automatic failover. This eliminates the configuration overhead that self-managed setups require.