Magento 2 Cache Type and how to clear cache in Magento 2

 

Magento 2 comes with advance Cache management in order to handle best performance optimization.

How to clear cache in Magento 2

Clear cache from admin section:

  • Login to admin section
  • Click on System (gear shape icon)
  • Click on Flush magento Cache button near top right
  • Select cache type and click on flush button

Clear cache from command line

php bin/magento cache:flush

Types of Cache in Magento 2


There are 12 different kind of cache in magento 2.

Friendly name Type name Description
Configuration config Magento 2 collects configuration from all modules, merges it, and saves the merged result to the cache including store configuration.
Layout layout Its compiled page layout. It contains layout from all the components
Block HTML output block_html HTML page fragments per block from all the modules
Collections data collections Results of database queries
DDL db_ddl Database schema
Entity attribute value (EAV) eav Value of eav attributes (store labels, links to related PHP code, attribute rendering, search settings)
Page cache full_page Generated HTML pages
Reflection reflection Removes a dependency between the Webapi module and the Customer module.
Translations translate Merged translations from all the modules
Integration configuration config_integration Compiled integrations(Clean or flush this cache after changing or adding integrations.)
Integration API configuration config_integration_api Compiled integration API
Web services configuration config_webservice Webservice API structure

Enable/Disable cache in Magento 2


You can enable/disable any of the cache at any moment. The command for disabling/enabling specific cache is

php bin/magent cache:enable –TYPENAME—

if you omit the typename then by default it will enable/disable all the modules.

Flushing specific type of cache


You can flush any specific type of cache. The meaning of flush is purges the cache storage. Which might affect other processes applications that are using the same storage. The command to flush magento storage is

bin/magento cache:flush –TYPENAME—

Omitting the typename flush all the cache types.

Clean specific type of cache


Cleaning a cache type deletes all items from enabled Magento cache type. 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:clean –TYPENAME—

Omitting the type name clean all the cache types.

Related posts:

The following two tabs change content below.

Chandra Shekhar

Consultant at Infogain
Chandra Shekhar is a LAMP Developer,Thinker,Blogger and currently working as Magento(Ecommerce) specialist.. I am always open to learn new things in LAMP as well as other newer technology. In the journey of my last 9 years of web and product development, I have decided to share my knowledge and experience to Open Source Community in 2011. In this regard I have started CuteHits.com. Since then I am actively sharing my knowledge on various LAMP technology through CuteHits.com’s technical ... Read More about Chandra Shekhar