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?
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?
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.
php bin/magento cache:clean
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.
php bin/magento cache:flush
Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage.
Reference: DevDocs Manage the cache
Quoting Fabrizio Branca for this one:
(...) Magento that comes with those two different actions in the first place (you'll also find two buttons on the cache management page).
While cache:clean deletes the cache storage by tags cache:flush will wipe out everything.
There are two major differences here:
- some things are stored into the cache without the proper tags. cache:clean will not delete those.
- other things might be using the same cache storage (this is not recommended, but sadly sometimes this is the case). Flushing the cache will result in everything being deleted. So if multiple Magento instances use the same cache storage or if you store your sessions in the same Redis database you're using for the cache (please don't! :) then they will also be gone.
Other resources:
php bin/magento cache:clean
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.
php bin/magento cache:flush
Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage.
Using bin/magento cache:clean
you can specify(comma-separated) cache types you want to clean.
Supported types:
config, layout, block_html, collections, reflection, db_ddl, eav,
customer_notification, target_rule, full_page, config_integration,
config_integration_api, translate, config_webservice
While cache:clean
deletes the cache storage by tags cache:flush
will wipe out everything.
There are two major differences here:
some things are stored into the cache without the proper tags. cache:clean will not delete those. other things might be using the same cache storage (this is not recommended, but sadly sometimes this is the case). Flushing the cache will result in everything being deleted. So if multiple Magento instances use the same cache storage or if you store your sessions in the same redis database you're using for the cache (please don't! :) then they will also be gone.
Source : https://github.com/netz98/n98-magerun/issues/588#issuecomment-112453280