Skip to content
Home » News » Magento 2 Cache Flush: Using Terminal or Admin Interface

Magento 2 Cache Flush: Using Terminal or Admin Interface

Magento 2 uses caching so that your store is faster and smoother by temporarily keeping data like layouts, configurations, and HTML content. But whenever you do something on your site and you don’t see the changes applied directly, then you might need to clear the cache.

You can manage cache in Magento 2 either by the command line (best suited for developers) or the Admin Panel (best suited for beginners). In this article, we will show you how to flush the cache, check its status, and enable it when needed.

What Is Cache in Magento 2?

Magento 2 stores different types of cache to improve speed and performance, including:

  • Configuration cache – saves settings and system configs
  • Layout cache – stores page layout data
  • Block HTML cache – saves HTML output for page blocks
  • Collections cache – optimizes the retrieval of data from the database.

You may find more information about cache types here.

Method 1: Flush Cache Using the Command Line

Steps:

  1. Connect to your server via SSH.
  2. Navigate to your Magento 2 root directory:
    cd /var/www/html/magento2
  3. Clean or flush the cache:

To clean the cache (recommended):

php bin/magento cache:clean

To flush all cache (including external systems):

php bin/magento cache:flush

Use cache:clean when you wish Magento to rebuild only what’s needed. Use cache:flush to completely clear everything, including third-party cache systems like Varnish.

Method 2: Flush Cache Using the Admin Panel

Steps:

  1. Log in to the Magento Admin Panel.
  2. Go to System > Cache Management.
System -> Cache Management in Magento admin
  1. You’ll see a list of cache types and their status.
  2. Click Flush Magento Cache to clear internal cache.
  3. Click Flush Cache Storage to clear all caches, including external ones.
Cache Management in Magento admin
  1. Or select specific cache types, then click Submit to clean only those.
Submit button in Cache Management in Magento admin

How to Check Cache Status via Command Line

You can easily verify which cache types are disabled or enabled.

Command:

php bin/magento cache:status

You will see a list with each cache type and its current state (enabled or disabled). For example:

config: 1
layout: 0
block_html: 1

1 = enabled and 0 = disabled.

How to Enable Cache in Magento 2 Using the Command Line

If you want to enable a disabled cache type:

To enable a specific cache type:

php bin/magento cache:enable layout

To enable all cache types at once:

php bin/magento cache:enable

How to Enable Cache Using the Admin Panel

Steps:

  1. Log in to the Magento Admin Panel.
  2. Go to System > Cache Management.
  3. Check the boxes next to the disabled cache types.
  4. From the Actions dropdown, choose Enable.
  5. Click Submit to apply changes.
Enable option in Cache Management in Magento admin

When Should You Flush or Enable Cache in Magento 2?

  • After you install or update extensions or themes
  • After you change store settings or configurations
  • When your site is not showing recent updates
  • After you deploy new code or files

Conclusion

Magento 2’s caching system is a powerful tool that can improve the site’s performance but must be managed appropriately. Whether managing through the terminal or the admin interface, having the ability to flush, check, and enable cache types will save time and headaches.

If you are new, the Admin Panel is user-friendly and safe. If you are experienced or you have a larger site, the command line is more versatile and quicker.

Author

Leave a Reply

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