Why to Flush or Clean Magento 2 Cache
- 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.
- Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage.
Magento 2 has 12 types of Cache with their respective description.
To Flush the Cache in Magento 2 using CLI
Go to the Magento Root Directory and Type the following
php bin/magento cache:clean php bin/magento cache:flush
This code will clear all the cache in the Magento 2
To See the Status of the Cache in Magento 2
Go to Magento Root directory and type the following
php bin/magento cache:status
This will return the following message
config: 1
layout: 1
block_html: 1
collections: 1
db_ddl: 1
eav: 1
full_page: 1
translate: 1
config_integration: 1
config_integration_api: 1
config_webservice: 1
Here 1 means the cache is enabled
Enable or Disable Cache Types
To Enable or Disable the specific cache types in Magento 2, you can use the following command
php bin/magento cache:enable [type] ... [type]
php bin/magento cache:disable [type] ... [type]
Example:
php bin/magento cache:enable db_ddl full_page
To Enable/Disable all Cache Types, type the following command
php bin/magento cache:enable php bin/magento cache:disable