Back to Top

How to check default cache is working in Magento 2?

Updated 27 June 2024

Now, we will learn how we can find that Magento 2 default cache is working fine on our website.

Default Cache Types in Magento 2: Magento 2 has the following default cache types:

(i) Layout
(ii) Block HTML output
(iii) Page cache
(iv) Translations

The above cache types mostly impact the frontend development process.

(v) Configuration

(vi) Collections data
(vii) DDL
(viii) Compiled Config
(ix) Entity attribute value (EAV)
(x) Reflection
(xi) Integration configuration
(xii) Integration API configuration
(xiii) Web services configuration
(xiv) Customer Notification

For detailed information about cache types, check Magento 2 documentation Manage the cache.

Searching for an experienced
Magento 2 Company ?
Find out More

How to check default cache is working?

In Magento 2 Admin section, Navigate to System -> Tools -> Cache Management Page.
Now, follow the below steps:

1. Select All the cache types and choose Enable option from the dropdown and click on Submit button.
After performing this action, all default cache types will be enabled. Refer to the below image:

Magento2 cache
Magento 2 Admin Cache Management Page

You can also enable the default cache type by using the following command:

php bin/magento cache:enable 

2. If cache types are already enabled, then skip step 1. And choose the Refresh option from the dropdown and click on Submit.

OR Click on the ‘Flush Magento Cache‘ button which is available on the top right side on the same page.

It will flush Magento 2 cache storage and prepare it for testing.

3. After flushing the cache, go to Magento 2 store website and perform some actions, for example: search for some products, add products to the cart, change some configurations at the admin end, etc.

4. After performing some action, navigate to Cache Management Page at the admin end. And check the status of each cache type in the grid.

If the Magento 2 default cache is working fine, then the status should change from “Invalidated” to “Enabled”.

It indicates that the default cache is storing and retrieving data correctly.

If any cache type shows a status other than “Enabled”, then there might be an issue with that specific cache.

In such cases, you can try disabling and re-enabling the cache types, and then flush the cache again to see if it resolves the issue.

You can also disable a specific cache type by using the following command:

php bin/magento cache:disable <cache_type> 

To disable all cache types, use the following command:

php bin/magento cache:disable 

Apart from the above method, you can also check the <magento-root-dir.>/var/cache/ directory on your server.

If the default cache is working fine, you will see new cache files are being created in this directory.
Refer to the below images:

Magento2 cache
Magento 2 var/cache/ directory
Magento2 cache
Magento 2 var/cache/mage–tags directory
Magento2 cache
Magento 2 var/cache/mage–e directory

There are a lot of directories in there (named like mage–0, mage–1, mage–2, mage–a etc.) and each directory has the cache files.

Execute the following command to list all files:

ls var/cache/mage*/*

Let’s understand about Configuration And Layout cache types files:

1. Configuration cache type files: In the <magento-root-dir.>/var/cache/mage–*/ directory, it contains configuration cache types files.

It varied on configuration updates. In your <magento-root-dir.>/pub/errors/local.xml and all config.xml files (which are available in each module’s etc directory) are combined together to make one big configuration object.

Then, Magento 2 reads from the core_config_data table to update the configuration object. Then the configuration is written to a cache file and cached in the cache directory and next time, when a request is made, it doesn’t need to open a lot of config files and hit the database.

It will get the information from the cache.

To check configuration cache type files, execute the following command:

ls var/cache/mage*/*CONF*

2. Layout cache type files: It is like the configuration cache type. In your Magento 2 instance, all layout XML files are merged into one layout configuration object, and then cached in the cache directory.

To know more about caching terminology, refer to this link.

If you want to check Full Page Caching, Please check this blog How to check Page is loaded from the cache in Magento 2.

Hope this will be helpful.

You can get more Magento 2 Blogs here.

Thanks 🙂

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home