When Magento Open Source cache management decides whether your store stays fast
Start with the situation most store operators recognize: a deployment went out, an admin changed a price or a content block, and the storefront still shows the old version. Or the opposite: someone cleared caches to fix a display problem, and the store slowed down for minutes afterward. Both outcomes come from the same place. A self-hosted Magento Open Source store keeps several cache layers, including the configuration and block caches inside Magento, generated code and static view files on disk, and, where it is installed, a full-page cache accelerator. Each layer has its own invalidation rules, and flushing the wrong one either leaves stale content in place or forces the store to rebuild expensive data while customers are browsing.
This page answers one practical question: when should you clean a cache type, when should you flush everything, and what should you do after a deployment so the new code is actually the code being served. Flushing is not always the right action because a full flush empties layers that would otherwise keep serving requests cheaply, so every rebuild lands on the database and the application at once. On a quiet store that cost is invisible. On a busy store it can produce a cache stampede, where many requests miss at the same moment and all try to regenerate the same data. The sections that follow set out the decision rules, the post-deployment sequence and the controls that reduce stampede risk.
Before you touch any cache, confirm which layers your installation actually uses. Adobe documents Varnish as the full-page cache accelerator for self-managed installations, so check whether your store runs it and how it is configured, because a Magento-side flush does not purge Varnish. Your web server, PHP settings and any CDN in front of the store are also part of the picture. Ask your team, or your partner, to write down each layer, who owns it and how it is invalidated. That single document prevents most of the confusion in the rest of this page and gives the cache-clearing steps a clear owner.
Which cache action fits which change
This table compares the cache actions available to a self-hosted Magento Open Source store and the change that each one fits. Read each row as a question: what did you just change, and what does the store need to see again? Confirm exact command names and cache type codes against the documentation for your version before running anything in production.
| Change made | Action to take | Why it fits |
|---|---|---|
| Content edits in admin (products, CMS pages, blocks) | Clean the affected cache tags or types, such as block_html or full_page | Only entries tagged with the changed data need to go, so the rest of the cache stays warm |
| Configuration change in admin or config.php/env.php | Clean the config cache type, then check the full-page cache | Stored configuration values are cached separately from page content and can persist after a save |
| Code deployment that changes PHP, layout XML or templates | Flush all caches and clear generated code (generated/ and var/cache) as part of the deploy | Old compiled classes, plugins and layout definitions can keep running after files change |
| Install or upgrade of a module or theme | Run the setup and compile steps, then flush all caches | Dependency injection and declarative schema changes must be recompiled before the store reads them |
| Emergency clean during a live incident | Clean only the cache types you have identified as stale, not a full flush | A full flush empties every cache at once and forces every request to rebuild data, which can overload the database and PHP workers |
| Full-page cache on self-managed installs | Use the Varnish purge path documented by Adobe for the installation | Adobe documents Varnish as the full-page cache accelerator for self-managed installs, so purging Magento's own cache alone may not clear pages served from Varnish |
| Full-page cache on cloud-hosted Adobe Commerce | Use the Fastly purge path, not Varnish | Adobe documents Fastly for cloud-hosted Adobe Commerce, so the Varnish steps do not apply to that hosting model |
| Scheduled or bulk catalog import on a busy store | Warm caches after the import completes, and stagger any flush | Flushing during peak traffic sends many concurrent requests to a cold cache, which is the stampede risk to plan around |
How to clear caches after a deployment without an outage
This sequence confirms the target, clears generated code and invalidated caches in a fixed order, warms the storefront gradually, and checks pages and logs so the store stays available and the release is verified.
Confirm the target environment and release
The engineer on call confirms the host, store root, and release directory before running anything, so cache commands never touch the wrong environment. They check the installed version with
bin/magento --versionand compare it with the release ticket. Confirm the deployment mode inapp/etc/env.phpand whether the release is the one approved for this window. The step is complete when the host, path, version, and mode match the change record.Record the cache baseline
Before changing anything, run
bin/magento cache:statusand save the output with the timestamp. This shows which cache types are enabled and which are invalidated, so the team can later confirm that only the expected types were cleaned. Note the state of cron and message queue consumers, since stalled background work can make cache state look wrong after a release. Sibling pages cover those checks in detail. The step is complete when the baseline is saved in the change log.Compile dependency injection and generated code
Run
bin/magento setup:di:compilein production mode so generated classes match the new code, and runbin/magento setup:static-content:deploywhen static files changed. Clearing stale generated code matters most after a deployment that changed plugins, preferences, or module classes. Build these outputs on the new release directory before the store points at it, so visitors do not hit partly generated files. Confirm the commands finish without errors in the console output. The step is complete when both commands exit cleanly and the generated directory matches the new release.Clean the invalidated cache types
Run
bin/magento cache:cleanfor the types the release affects, such as config, layout, block_html, and full_page, instead of defaulting to a full flush. Cleaning only the affected types keeps unrelated caches warm and reduces the load spike on the database when pages rebuild. Usebin/magento cache:flushonly when Adobe's documentation or the release notes call for it, because it clears every cache type at once. Re-runbin/magento cache:statusto confirm the expected types are invalidated or cleared. The step is complete when the status output matches the plan.Purge the full-page cache layer
If the store uses Varnish as the full-page cache accelerator in a self-managed setup, purge or refresh it according to your Varnish configuration after the Magento cache is cleaned. Purging Varnish first can send requests to an application that is still rebuilding, so keep this step after the Magento clean. Confirm the purge request returns success and that the Varnish layer is serving content from the new release. Check the vendor documentation for the exact purge method your version supports. The step is complete when the purge is confirmed and responses carry the expected headers.
Warm caches at a controlled pace
Request a short, fixed list of storefront pages such as the home page, a top category, a high-traffic product, and the cart, using a script that adds a delay between requests. Warming gradually prevents many visitors from triggering the same expensive page rebuilds at once, which is the cache stampede risk on busy stores. Start with low concurrency and increase only if response times stay steady. Confirm each page returns a successful status and that rendered prices and stock match the back end. The step is complete when the warm list finishes with no errors and steady response times.
Verify storefront and admin pages
Test the storefront path a shopper uses, including search, a product page, adding to cart, and reaching checkout up to payment, using a test account or a staging-safe method. Sign in to the admin panel, open a recently changed configuration screen, and confirm the change shows the new value. Compare results with the release notes so changed behavior is expected, not mistaken for a fault. Record the test accounts and pages checked. The step is complete when the scripted and manual checks pass and the results are logged.
Review logs and close the change
Review
var/log/system.log,var/log/exception.log, and the web server error log for entries written after the deployment time, and confirm no new fatal errors or repeated warnings appear. Compare the counts with the pre-release baseline if you have one. Keep the previous release directory and the cache baseline until the team agrees the release is stable. Refer to the sibling log reading page for interpreting each file. The step is complete when the log review is recorded, and the change ticket states the verification result and the rollback point.
Why generated code and static content need clearing after a release
A code release can leave Magento Open Source serving output built from the previous code. Generated code, including compiled dependency injection definitions and proxy classes, lives in the generated directory, and static view files such as compiled CSS, JavaScript and theme assets are published under pub/static. When a new release changes a module, a plugin, a layout or a theme file, these artifacts can still reflect the old code until they are rebuilt or removed. The symptoms are often subtle: a changed constructor argument that still resolves to the old class, a theme change that does not appear on the storefront, or an error that only occurs for some visitors. The reliable fix is to make the deployment itself regenerate and republish these directories, not to rely on someone remembering to flush a cache by hand after the switch. Confirm, for your own release layout, exactly which directories your build writes to and which ones your deploy script clears, because the list depends on how you run setup:di:compile and setup:static-content:deploy and on whether those steps run before or after traffic reaches the new code.
Multi-node layouts add a second risk. Web nodes that share a deployment directory, or that mount var, generated or pub/static from shared storage, can end up with partial clears if one node cannot delete or rewrite files owned by another user, or if a process runs as a different owner than the web server. A cache clear that reports success on one node can leave another node serving stale artifacts, and the failure may appear only intermittently behind a load balancer. Check that the user running the build and the user running PHP-FPM have matching write access to every generated path, that file ownership is the same on every node, and that the deploy step builds once and distributes an identical release rather than compiling separately on each server. Ask your team or partner to document which path is shared, which is node-local, and what a failed step looks like in your logs. Before relying on any sequence, test it on a staging layout that mirrors production, since permission problems are easy to miss when a single developer machine runs everything as root.
The practical decision is where clearing belongs in the pipeline. Treat generated code and static content as build outputs: compile and deploy them in the release process, verify the result on a staging copy, and only then switch traffic. Manual flushing of cache types is useful for diagnosis, but it does not repair a stale generated directory on a node that was never updated, and it can create a window where requests hit an unprepared store. Ask your release owner to confirm the exact commands, the maintenance window they require and the order of operations relative to the Varnish or Redis layers that sit in front of or behind the application, and to record that order in the runbook before the next release.
How cache stampedes happen on busy stores and how to reduce them
A full cache flush on a busy Magento Open Source store forces many requests to rebuild cached data at the same moment, and that load lands on the database, indexers and PHP workers together. The cards below are decisions and checks that reduce the chance of that spike, and each one should be tested against your own traffic pattern before you rely on it.
Flush narrow cache types first
Start by identifying which cache type actually holds the stale data, and clean only that type instead of flushing everything. A narrow clean rebuilds a small set of entries, so fewer requests hit the database at once. Check the cache type list in the admin before any action, and confirm which types your extensions register, since third-party modules can add their own. Keep a written note of which type you cleaned and why, so the next operator does not repeat a full flush out of habit.
Varnish cache docsSchedule flushes in low-traffic windows
Any operation that empties a large part of the cache causes rebuild traffic, so time it for the quietest period your store sees. Use your analytics to find that window per storefront and per market, since a single global quiet hour may not exist for multi-region stores. Agree on the window with merchandising and marketing teams so promotions and campaign launches are not scheduled into the same period. Confirm who has authority to approve an out-of-window flush during an incident.
Warm key pages after clearing
After a targeted clean, request the home page, top category pages and best-selling product pages from a script so the cache is repopulated under controlled load instead of by the first shoppers. Keep the list of URLs short and reviewed, and throttle the requests so the warming job does not become the stampede. Confirm that warming reaches the same cache layer your visitors hit, since warming a local cache does not help a CDN edge or a separate full-page cache.
Size Redis or Valkey for rebuild load
Cache and session data often sit in Redis or Valkey, and a broad rebuild can fill memory or drive eviction faster than normal traffic. Check the memory limit, eviction policy and the separation between cache and session databases against the versions listed for your release. Measure memory use before and after a planned clean in a staging environment that mirrors production data volume. Ask your team to confirm whether sessions and cache share one instance, because that choice changes the blast radius of a flush.
System requirementsSize PHP-FPM workers for the spike
When many cache misses reach PHP at once, the number of available PHP-FPM workers decides whether requests queue or fail. Review the worker pool limits, request timeouts and the memory each worker uses under a full storefront render. Compare these limits with the peak concurrency your load balancer allows, so queued requests do not pile up behind slow database calls. Treat the pool size as a value to test under load, not a number to copy from another store.
Use Varnish or Fastly rules to absorb traffic
A full-page cache in front of the application can serve most anonymous page views without touching PHP, which reduces the number of requests a flush exposes. Self-managed stores typically run Varnish, while cloud-hosted Adobe Commerce uses Fastly, so the rules and purge behavior differ by platform. Review which URLs, cookies and query parameters are cacheable, and confirm that purge requests target only the affected pages. Test purge scope in staging before relying on it during a live event.
Use Varnish cacheQuestions buyers ask about Magento Open Source cache management
What does cache management work cost, and what drives the price up?
Cache management is usually a small part of a larger engagement, so the cost depends on what the work is attached to. The main drivers are the number of cache types in use, whether full-page caching runs on Varnish or another accelerator, how many custom modules and extensions touch caching, and how many storefront and admin paths need testing after changes. Ask for a quote that splits the work into a one-time review and setup, a written flush and warm-up procedure for your team, and any recurring monitoring or retainer support. DeployOpen does not publish a price list, and a quote follows from the written scope.
How long does a Magento cache review take?
The duration depends on the size of the store, how many custom components interact with caching, and whether you already have a documented procedure. A review covers the cache types Magento Open Source exposes, how your full-page cache is configured, the deployment steps that regenerate code, and the traffic patterns that expose stampede risk. Stores with clean extension sets and existing runbooks move faster. Stores with heavy custom caching logic or multiple nodes need more time for testing. Ask for the review steps and the environments needed to test them before agreeing a schedule.
What must our team provide before a cache review starts?
Your team should provide read access to the codebase, the deployment pipeline, and the current web server and cache configuration. You should also share the Magento Open Source version in use, the PHP, Redis or Valkey, and Varnish or other accelerator settings, and any extensions that cache data. A staging environment that resembles production in size and topology is essential for testing flushes under load. Name one person who can approve changes during the engagement and who knows the traffic calendar, so that cache tests avoid peak trading periods.
Can our in-house team run cache flushing and cleaning without a partner?
Yes, many in-house teams run routine cache operations well once the procedure is written down. Routine cleaning of a single cache type is a low-risk task. Full flushes, clearing generated code after a deployment, and changes to full-page cache configuration carry more risk, especially on busy stores with several nodes. An in-house team needs a documented decision guide, a tested warm-up method, and monitoring that shows database and PHP load during flushes. A partner can write that runbook, train the team, and review the first few production changes.
How do cache changes interact with Magento upgrades and extensions?
Upgrades usually require clearing generated code and rebuilding caches, so the cache procedure should be part of the upgrade plan, not an afterthought. Adobe's upgrade guide names customizations, extension count, third-party integrations and coding practices as drivers of upgrade effort, and those same components often add cache types, cache tags or custom invalidation logic. Before each patch or minor upgrade, check that each extension declares its cache behavior correctly and that the Upgrade Compatibility Tool reports no blocking issues. Confirm the Adobe security patch cadence for your release line in Adobe's release schedule before planning each window.
Which Magento Open Source versions and stack components affect cache behavior?
The Magento Open Source version determines which PHP, cache backend and accelerator combinations Adobe supports, so check the system requirements for your exact release before changing cache settings. For example, the 2.4.9 requirements list Redis or Valkey 9 and Composer 2.10, while the 2.4.8-p5 requirements list Redis or Valkey 8.1 and Varnish 8. Adobe documents Varnish as the full-page cache accelerator for self-managed installations. Confirm the supported list in the official documentation before you change any cache backend version.
What is a cache stampede, and how do we prevent it on a busy store?
A cache stampede happens when many requests miss an expired or flushed cache at the same moment and all rebuild the same data, which can overload the database and PHP workers. The usual controls are flushing only the cache types you need, scheduling broad flushes during low traffic, warming critical pages before opening traffic, and checking that your accelerator and cache backend can absorb the rebuild load. Test these steps on a staging copy of production traffic patterns. Ask your partner to document which flushes are safe during trading hours and which require a maintenance window.
How a request moves through the cache layers
A storefront request starts at the browser and reaches either Varnish (self-managed full-page cache) or the web server, depending on how the store is hosted. On a miss, the request goes to the Magento application, which reads its block and configuration caches before querying the database and indexes. Generated code and static view files sit beside the application and are the layers a deployment most often leaves stale. Check which layer served the response before you flush, because flushing the wrong layer wastes time and can trigger a rebuild storm on a busy store.
Request path from browser to database, with generated code, static files and flush points marked.
How DeployOpen works on this
DeployOpen plans, implements, hardens, documents and supports self-hosted Magento Open Source inside your own infrastructure. For cache work, that means defining which cache types your store needs cleaned or flushed, building the deployment steps around them, and leaving your team with a runbook it can follow under pressure.
How we scope
- Written scope lists the cache types, deployment workflow and busy-period constraints the engagement covers before work starts.
- We review your current deployment pipeline, web server and Varnish setup to decide which flush steps belong in release automation.
- Engagements are fixed-scope, so deliverables and timelines for cache work are agreed in writing before the build begins.
- Ask for the scope to name each environment (staging, production, multi-node) and the Magento version it targets.
How we build
- We write and test the cache clean and flush procedures in a non-production environment that matches your production topology.
- Generated code cleanup and static content deployment steps are scripted and run in the same order every release.
- Stampede controls such as warm-up sequencing and cache-aware traffic handling are tested under a load pattern agreed in scope.
- Configuration changes are reviewed against your hardening baseline before they reach the live store.
How we hand over
- You receive a written runbook covering each cache type, the exact commands used, expected effects and rollback steps.
- Documentation records which Varnish or CDN purge actions depend on your infrastructure, so your operators know what they control.
- A walkthrough with your engineers and operators covers the runbook, and they run the procedure once with us observing.
- Handover notes list open questions to confirm with your hosting provider, such as purge API access and node-level cache locations.
How we support
- Ongoing support, Magento upgrades and continuous testing are available as retainers when your store changes after launch.
- When a Magento patch or release changes cache behavior, we update the runbook and retest the affected procedures.
- Support requests are handled under the retainer terms agreed in writing, including which environments and cache types they cover.
- Ask any provider how cache procedures will be retested after each Magento patch cycle, and who owns that retest.

