Magento 2 Cache Clean vs Cache Flush – Key Differences

cachecommand linemagento2

In Magento 2 we have 2 commands

php bin/magento cache:flush
php bin/magento cache:clean

What's the exact difference between them? I'm generally using cache:flush. I never used cache:clean. So, when to use which command & in which situation?

Best Answer

To purge out-of-date items from the cache, you can clean or flush cache types:

  • Cleaning a cache type deletes all items from enabled Magento cache types only. In other words, this option does not affect other processes or applications because it cleans only the cache that Magento uses.

    Disabled cache types are not cleaned.

  • Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage.

Flush cache types if you’ve already tried cleaning the cache and you’re still having issues that you cannot isolate.

Source: https://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cache.html#config-cli-subcommands-cache-clean

Related Topic