Magento 2

How to clear the cache in Magento 2 (clean and flush)

December 10, 2021

How to clear the cache in Magento 2 (clean and flush)

In this article we will learn how to clear the cache in Magento 2, through the terminal and also some concepts that involve this action (clean and flush).

clear the cache in Magento 2 cover

Hey you programmer, okay? Let’s learn how to clear Magento’s cache! 

Caches can get in the way of testing in the development environment or updating content in production

That’s why it’s important to clear the caches with each new change.

But remember that the cache makes your site load faster, just because it already pre-store the information

So with every cache cleanup in production you can experience a drop in performance, which can be frowned upon your site

| Do you want to specialize in Web Development? Check out  our course catalogue.

That said, in Magento 2 unlike Magento 1, we can clear caches via the terminal, which makes this action much more productive and faster

We can choose two commands, here they are:

php bin/magento cache:flush
php bin/magento cache:clean

The clean command clears all enabled Magento caches

And it only clears the native caches that Magento uses

Flush clears the cache storage, in other words, it can affect other third-party processes that save their files in the cache folder

Other cache-related possibilities that Magento gives us is to check the cache status

That is, check which caches are enabled and also disabled

php magento/bin cache:status

And of course, we can enable or disable all caches, with the following commands respectively:

php magento/bin cache:enable
php magento/bin cache:disable

If it is some specific type of cache, for example layout, we can use the command like this:

php magento/bin cache:enable layout
php magento/bin cache:disable layout

Conclusion

In this article we learned several cache commands in Magento 2, and mainly how to clear the cache

We use the clean and flush command for this action

The clean command clears all Magento-related caches except disabled ones

The flush command, on the other hand, clears all caches, even third-party extensions, that follow Magento’s cache standards

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x