Magento 2 Cache
Magento 2 Cache tutorial on different usage scenarios and why Cache should be enabled on your store.
How Cache Works #
Cache » works by Pages (or parts of pages) that are stored, and not generated on each request, to improve the page load time of subsequent requests.
Cache Enable #
Magento 2 enable cache is a action you can do from different application areas.
Cache Enable Backend #
- Login into the Magento Admin area
- Go to
System > Tools > Cache Management
- Select the desired Cache Types and click Enable
Cache Enable Command Line #
To enable cache you can execute following command:
$ bin/magento cache:enable
The output of cache disable can be:
There is nothing to change in cache status
if cache is already enabled, or:
Changed cache status:
config: 0 -> 1
layout: 0 -> 1
block_html: 0 -> 1
collections: 0 -> 1
reflection: 0 -> 1
db_ddl: 0 -> 1
compiled_config: 0 -> 1
eav: 0 -> 1
customer_notification: 0 -> 1
full_page: 0 -> 1
config_integration: 0 -> 1
config_integration_api: 0 -> 1
translate: 0 -> 1
config_webservice: 0 -> 1
Cleaned cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
full_page
config_integration
config_integration_api
translate
config_webservice
if cache was previously disabled.
Cache Disable #
Disabling cache in Magento 2 has an adverse effect on performance so only disable if your server has enough resources available to handle all the requests. It is highly recommended to have the Cache Enabled in a production environment.
Cache Disable Backend #
- Login into the Magento Admin area
- Go to
System > Tools > Cache Management
- Select the desired Cache Types and click Disable
Cache Disable Command Line #
To disabled cache you can execute following command:
$ bin/magento cache:disable
The output of cache disable can be:
Changed cache status:
reflection: 1 -> 0
db_ddl: 1 -> 0
compiled_config: 1 -> 0
eav: 1 -> 0
customer_notification: 1 -> 0
config_integration: 1 -> 0
config_integration_api: 1 -> 0
translate: 1 -> 0
config_webservice: 1 -> 0
Cache Clean #
Cache Clean Backend #
You can Clean Cache via admin area by going to:
Go to System > Tools > Cache Management > Select Cache Types and click “Clean”
Cache Clean Command Line #
To clean the Magento cache you can use below command:
$ bin/magento cache:clean
The output of the cache clean can be:
Cleaned cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
full_page
config_integration
config_integration_api
translate
config_webservice
Cache Flush #
If you tried Cache Clean and you are still having issues with cached parts of the application. Flushing the cache will result in everything being deleted so it’s a last resort type solution.
To flush the cache you can use command below:
$ bin/magento cache:flush
The output of the cache flush can be:
Flushed cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
full_page
config_integration
config_integration_api
translate
config_webservice
Cache Status #
To view the current status of the cache execute following command:
$ bin/magento cache:status
The output of the cache status can be:
Current status:
config: 1
layout: 1
block_html: 1
collections: 1
reflection: 1
db_ddl: 1
compiled_config: 1
eav: 1
customer_notification: 1
full_page: 1
config_integration: 1
config_integration_api: 1
translate: 1
config_webservice: 1
Cache Types #
Cache type name | Cache type code | 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 magento setup:db-schema:upgrade command. |
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. |
Magento 2 Upgrade
The guide to upgrade Magento 2 stores using Composer, Wizard or Manually and how to handle Errors during the process.
ReadMagento 2 Redis
Magento 2 Redis Tutorial, How to Install and Configure for Default Cache, Page Cache and Sessions Storage.
ReadMagento Security Scan Tool
Magento Security Scan is a tool provided by the Magento team that monitors your Ecommerce store and notifies you of security breaches.
ReadMagento 2 Extension
Magento 2 Extension tutorial, learn what is a Magento 2 Extension how to install or disable in your Magento store.
ReadMagento 2 Import
Magento 2 Import tutorial and How To for Products Import, Categories Import, Customers Import or Tax Rates Import.
ReadMagento 2 SEO
In this SEO guide we will help you get higher rankings by providing Magento 2 SEO Tips
Read