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?
- 
 Please read Magento 2 Cache Overview And Solution with this post helpful to understand difference between Cache Clean & Cache FlushMukesh Prajapati– Mukesh Prajapati2021年10月20日 11:04:44 +00:00Commented Oct 20, 2021 at 11:04
6 Answers 6
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.
- 
 2Can I know which are the other processes applications which will use Magento cache storage.Jaya chandra– Jaya chandra2019年09月04日 14:39:07 +00:00Commented Sep 4, 2019 at 14:39
- 
 You can enable performance in Magento by configuring Configuring Redis for backend cache,Configuring Memcached for session caching and Configuring Varnish as a Full Page Cache (This is explained in detail in Magento 2 Cook Book by Ray Bogman). The other applications in sense if you have a single Redis or any other server running and configured with more than one Magento or any other applications. Running Flush will delete all directory + files but running clean will delete files alone in \Magento\var\cache dir.Bala Varadarajan– Bala Varadarajan2019年10月23日 09:11:13 +00:00Commented Oct 23, 2019 at 9:11
- 
 1@BalaVaradarajan I'm afraid I don't get it. Does anyone do that? I wouldn't come up with the idea to share a cache with different applications or Magento instances. Sounds very special.robsch– robsch2020年01月22日 07:27:17 +00:00Commented Jan 22, 2020 at 7:27
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
- 
 Thanks @Rafael. So which is best & when to use?Jackson– Jackson2016年09月27日 01:49:49 +00:00Commented Sep 27, 2016 at 1:49
- 
 Depends, but I prefer cache:clearRafael Corrêa Gomes– Rafael Corrêa Gomes2016年09月27日 01:59:13 +00:00Commented Sep 27, 2016 at 1:59
- 
 I've tried to create an empty file on var/cache and it was not deleted by any of these commands as you mentioned. But thanks for that anyway.Ricardo Martins– Ricardo Martins2018年09月27日 09:08:15 +00:00Commented Sep 27, 2018 at 9:08
- 
 @RicardoMartins it is because you need to create a file like var/cache/mage--test-martinesRafael Corrêa Gomes– Rafael Corrêa Gomes2018年09月28日 12:59:44 +00:00Commented Sep 28, 2018 at 12:59
- 
 This answer is the opposite of the chosen answer If I am correctPatrick van Efferen– Patrick van Efferen2019年01月14日 13:03:27 +00:00Commented Jan 14, 2019 at 13:03
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
- 
 You can do that with cache:flush as well. See devdocs.magento.com/guides/v2.3/config-guide/cli/….Ricardo Martins– Ricardo Martins2019年04月17日 04:10:39 +00:00Commented Apr 17, 2019 at 4:10
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