Magento 2 Cache Management - The Full Guide
Posted on 15 March 2018
Magento 2 has is a caching system that improves the speed of the platform. There are 13 cache types which are difficult to disentangle. Let's take a closer look at cache management features and available actions on the System > Tools > Cache Management page.
There is a table with 13 cache types on Cache Management page. You can view their status, enable, disable or refresh cache types as well as flush or clear common cache.
Cache code: config
Description: The Configuration cache type stores information about the settings of the magento itself, as well as information about the settings of modules which can be configured at in stores > configuration page
Cache code: layout
Description: Information about page layouts is stored in the Layouts cache type. In other words, these are instructions for building the main page layout.
Blocks HTML Output
Cache code: block_html
Description: Blocks HTML Output cache type helps to cache fragments of HTML pages. These fragments are stored for each block of HTML pages.
Cache code: collections
Description: Data cache type contains the results of querying the database, which speeds up the execution of requests when the database is questioned again. Magento 2 platform can automatically update this type of cache.
Cache code: reflection
Description: This cache type works with reflection data for API interfaces. It’s used to remove a connection between Customer module and WEB API module.
Database DDL operations
Cache code: db_ddl
Description: Database schema. This cache type contains results of DDL queries, for example table or index description. This cache can also be used by 3rd-party developers. Usually, Magento 2 platform update this cache automatically if necessary. You can also update the database scheme with this command:
EAV types and attributes
Cache code: eav
Description: Entity types declaration cache. This cache type contains metadata which is associated with EAV (entity-attribute-value model) attributes. It requires configuration to be loaded from the database. It can contain links to PHP code, store labels, settings of search, attributes rendering and so on. Usually, there is no need to flush this cache manually.
Cache code: customer_notification
Description: This types caches customer notifications.
Page Cache (Full Page Caching)
Cache code: full_page
Description: This cache type stores generated HTML pages (product pages, categories, cms pages). This cache type can also be used by 3rd-party developers - they can put data into segments of FPC. We always recommend enable this cache type as it dramatically improves storefront speed. Magento 2 FPC can be configured at Stores > Configuration > Advanced > System > Full Page Cache.
FPC is available for both Community and Enterprise Magento 2 editions (aka Open Source and Commerce). But in Magento 1.x FPC is not included in Community Edition, that is why merchants are using Full Page Cache extensions.
Cache code: config_integration
Description: It contains compiled integrations. Please remember to clear this cache type if you added or changed any integrations.
Integrations API Configuration
Cache code: config_integration_api
Description: This cache type contains compiled integration APIs.
Cache code: translate
Description: Text labels displayed on the storefront and in admin panel can be translated to different locales per store views. This cache types stores those translations of all modules. It’s a big CSV file which is combined into one file from all the CSV files used for translations.
Useful tip:The original files with translations in Magento 1.x are stored in the app/locale/xx_XX/ folders. But Magento 2 translations are stored another way - translations are stored in /app/code/Vendor/Module/i18n/xx_XX.csv files.
Web Services Configuration
Cache code: config_webservice
Description: It is used to cache all API connections (Web API Structure)
Managing Magento 2 Cache
How to Enable/Disable Cache from Magento 2 admin panel
You can enable/disable/refresh any cache type manually at System > Tools > Cache Management page. Simply select cache type(s), then select “Enable” action in the left top corner, and click on Submit button.
Manage Cache Types with Commands
Alternatively, you can use command lines to enable, clear or disable any cache type.
Get cache status:
Disable any cache type:
magento cache:enable [cache_code1] [cache_code2] ... [cache_codeN]
magento cache:disable [cache_code1] [cache_code2] ... [cache_codeN]
magento cache:disable db_ddl full_page
Difference between Cache Clearing and Cache Flushing
Disabled cache type can not be cleared, but can be flushed.
You can clear and flush cache this way:
magento cache:clean [cache_code1] [cache_code2] ... [cache_codeN]
magento cache:flush [cache_code1] [cache_code2] ... [cache_codeN]
magento cache:clean db_ddl full_page
The following actions available on Cache Management page:
- “Flush Cache Storage” button - it clears all the items in the cache storage. Please keep in mind that this action can also affect the operation of 3rd-party modules and applications.
- “Flush Magento Cache” button - it clears cache tags and entries and in the var/cache folder. Basically, it calls function “flush()” in the model “core/cache”.
- “Flush Catalog Images cache” button - it clears all images which are located in media/catalog/product/cache folder.