← lessons

Configure automatic cache clearing in Magento

Video Lesson: Configure automatic cache clearing in Magento

Automatically clear specific caches in Magento when files change during development.

Mark Shust

TEACHER

Mark Shust

Published 4 months ago

Share with colleagues:

Share on X Share on LinkedIn

Lesson Content

Magento's cache system is great for production, but constantly clearing caches during development can really slow you down. Let's fix that with the magento-cache-clean module, which automatically clears specific caches when you need them cleared.

First, install it as a dev dependency with Composer:

composer require --dev mage2tv/magento-cache-clean

Once installed, start the watcher:

vendor/bin/cache-clean.js --watch

The watcher monitors your Magento files and automatically clears related cache types when files change. For example, if you update a template file, it'll only clear the block and full page caches — leaving all the other cache types untouched.

This will provide you with two major benefits:

  1. You'll rarely need to manually flush the cache again. The watcher handles nearly every cache clear scenario automatically. That said, you may still need to clear specific caches occasionally for uncommon scenarios, like creating new themes or updating rare XML configurations.

  2. You can keep all caches enabled during development. Since the watcher flushes the cache intelligently, this will provide you with a significant performance boost when coding.

Note: If you're using the docker-magento development environment, cache-clean is already included and configured — none of this setup is needed. Just go forth and code!


M.academy University
Join the All-inclusive
Magento learning University

Level-up your career with the complete Magento development solution.

Full premium course catalog

Personalized AI tutor

Friendly developer community

Learn more →
M Bytes Newsletter
Bi-weekly Magento deep-dives

Watch. Read. Apply. One topic every other week.

Fresh bytes every other Thursday. No spam. Unsubscribe anytime.


Join 9,000+ developers learning Magento, one byte at a time.