Manage the cache
In addition to the command arguments described in this topic, see Common arguments.
Run all Magento CLI commands as the Magento file system owner.
Overview of cache types
Magento 2 has the following cache types:
|Cache type “friendly” name||Cache type code name||Description|
|Configuration||config||Magento collects configuration from all modules, merges it, and saves the merged result to the cache. This cache also contains store-specific settings stored in the file system and database. Clean or flush this cache type after modifying configuration files.|
|Layout||layout||Compiled page layouts (that is, the layout components from all components). Clean or flush this cache type after modifying layout files.|
|Block HTML output||block_html||HTML page fragments per block. Clean or flush this cache type after modifying the view layer.|
|Collections data||collections||Results of database queries. If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache. Clean or flush this cache type if your custom module uses logic that results in cache entries that Magento cannot clean.|
|DDL||db_ddl||Database schema. If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache. Clean or flush this cache type after you make custom changes to the database schema. (In other words, updates that Magento does not make itself.) One way to update the database schema automatically is using the
|Compiled Config||compiled_config||Compilation configuration|
|Entity attribute value (EAV)||eav||Metadata related to EAV attributes (for example, store labels, links to related PHP code, attribute rendering, search settings, and so on). You should not typically need to clean or flush this cache type.|
|Page cache||full_page||Generated HTML pages. If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache. Clean or flush this cache type after modifying code level that affects HTML output. It is recommended to keep this cache enabled because caching HTML improves performance significantly.|
|Reflection||reflection||Removes a dependency between the Webapi module and the Customer module.|
|Translations||translate||After merging translations from all modules, the merger cache will be cleaned.|
|Integration configuration||config_integration||Compiled integrations. Clean or flush this cache after changing or adding integrations.|
|Integration API configuration||config_integration_api||Compiled integration APIs configuration of the Store’s Integrations.|
|Web services configuration||config_webservice||Caching the Web API Structure.|
|Customer Notification||customer_notification||Temporary notifications that appear in the user interface.|
View the cache status
To view the status of the cache, enter
1 bin/magento cache:status
A sample follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 config: 1 layout: 1 block_html: 1 collections: 1 reflection: 1 db_ddl: 1 compiled_config: 1 eav: 1 customer_notification: 1 config_integration: 1 config_integration_api: 1 google_product: 1 full_page: 1 config_webservice: 1 translate: 1 vertex: 1
Enable or disable cache types
This command enables you to enable or disable all cache types or only the ones you specify. Disabling cache types is useful during development because you see the results of your changes without having to flush the cache; however, disabling cache types has an adverse effect on performance.
Starting in version 2.2, you can only enable or disable cache types using the command line while running Magento in production mode. If running Magento in developer mode, you can enable or disable cache types using the command line or manually. Before doing so, you must manually make
<magento_root>/app/etc/env.php writeable by the Magento file system owner.
You can clean (also referred to as flush or refresh) cache types using either the command line or the Magento Admin.
1 bin/magento cache:enable [type] ... [type]
1 bin/magento cache:disable [type] ... [type]
[type] enables or disables all cache types at the same time. The
type option is a space-separated list of cache types.
To list cache types and their status:
1 bin/magento cache:status
For example, to disable the full page cache and the DDL cache:
1 bin/magento cache:disable db_ddl full_page
1 2 3 Changed cache status: db_ddl: 1 -> 0 full_page: 1 -> 0
Enabling a cache type automatically clears that cache type.
As of version 2.3.4, Magento caches all system EAV attributes as they are retrieved. Caching EAV attributes in this manner improves performance, because it decreases the amount of insert/select requests to the DB. However, it increases cache network size as well. Developers can cache custom EAV attributes by running the
bin/magento config:set dev/caching/cache_user_defined_attributes 1 command. This can also be done from the Admin while in Develop mode by setting Stores > Settings Configuration > Advanced > Developer > Caching Settings > Cache User Defined Attributes to Yes.
Clean and flush cache types
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.
Always clean the cache after upgrading versions of Magento Open Source or Magento Commerce, upgrading from Magento Open Source to Magento Commerce, or installing Magento Commerce for B2B or any module.
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.
1 bin/magento cache:clean [type] ... [type]
1 bin/magento cache:flush [type] ... [type]
[type] is a space-separated list of cache types. Omitting
[type] cleans or flushes all cache types at the same time. For example, to flush all cache types, enter
1 bin/magento cache:flush
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Flushed cache types: config layout block_html collections reflection db_ddl compiled_config eav customer_notification config_integration config_integration_api full_page config_webservice translate
You can also clean and flush cache types in the Magento Admin. Go to System > Tools > Cache Management. Flush Cache Storage is equivalent to
bin/magento cache:flush. Flush Magento Cache is equivalent to