How to Flush, Enable, Disable Cache Command Line in Magento 2

The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

How to flush the Cache Command Line in Magento 2 one of the top concerns when you are using Magento store. Magento 2 has 12 cache types by default. There are 5 simple commands to manage cache in command line. In this post I will show you to conduct each command line step by step.

Free Magento 2 Clean Cache extensions

Related topics:

Magento 2 How to Flush Cache Command Line

What are Magento 2 Caches? Why should you flush Cache?

Magento 2 Caches, which store data for quicker future data calls, are responsible for improving the site’s speed. Cache types include the Configuration, Layout, DDL, Collections data, Block HTML output, Compiled Config, Page cache, Reflection, Entity attribute value, Translation, Customer Notification, Integration configuration, Integration API configuration, and Web services configuration.

Whenever you make any change to your store, it is essential that you refresh the caches to display those changes on the frontend. If there is a need to refresh the caches, there will be a notice in yellow stating that you have to go to the Cache Management page to do so. Now let’s take a look at the following screenshot:

Magento 2 Flush Cache Command Line

How to flush Magento 2 cache

  • Go to Magento root directory

Flush Cache Storage

php bin/magento cache:clean

A short command line:

php bin/magento c:c

Flush Magento cache

php bin/magento cache:flush

A short command line:

php bin/magento c:f

How to change current directory in Ubuntu, Centos or Windows

  • Ubuntu: cd /var/www/magento2
  • CentOS: cd /var/www/html/magento2
  • Windows: cd /d/xampp/htdocs/magento2

In Windows case, I suppose that you should install Xampp in D drive.

In Magento 2, let try to show command line guide by php bin/magento, it will show like this:

Magento CLI version 2

 command [options] [arguments]

 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question

Available commands:
 help                                      Displays help for a command
 list                                      Lists commands
 admin:user:create                         Creates an administrator
 admin:user:unlock                         Unlock Admin Account

 cache:clean                               Cleans cache type(s)
 cache:disable                             Disables cache type(s)
 cache:enable                              Enables cache type(s)
 cache:flush                               Flushes cache storage used by cache type(s)

In this guide, I will talk more about Cache management in the command line.

How to check cache status

First of all, let show cache status by the following command line:

php bin/magento cache:status

Result of cache status

Current status:
                        config: 1
                        layout: 1
                    block_html: 1
                   collections: 1
                    reflection: 1
                        db_ddl: 1
                           eav: 1
            config_integration: 1
        config_integration_api: 1
                     full_page: 1
                     translate: 1
             config_webservice: 1

Clean Cache command line (SSH)

php bin/magento cache:clean

Flush cache storage used by cache types(s) command line

The cache storage may contain additional data such as server cache.

php bin/magento cache:flush

Disable Cache command line

The following command will disable all cache types

php bin/magento cache:disable

If you would like to disable specific cache type, you should type command line

php bin/magento cache:disable CACHE_TYPE


php bin/magento cache:disable config

How to enable Cache command line

It is similar to how to Disable cache all types and specific cache type

Enable all cache types

php bin/magento cache:enable

Enable specific cache type

php bin/magento cache:enable CACHE_TYPE


php bin/magento cache:enable layout

How to Clear Cache Programmatically

In case of development, a developer or a request from a merchant, he/she needs to clear / flush cache programmatically. So today we will show you how to Clear Cache Programmatically. Implement these lines of codes in Helper:

use Magento\Framework\App\PageCache\Version;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Cache\Frontend\Pool;
protected $cacheTypeList;
protected $cacheFrontendPool;
public function __construct(
    TypeListInterface $cacheTypeList, 
    Pool $cacheFrontendPool
    $this->cacheTypeList = $cacheTypeList;
    $this->cacheFrontendPool = $cacheFrontendPool;
public function flushCache(Version $subject)
  $_types = [
    foreach ($_types as $type) {
    foreach ($this->cacheFrontendPool as $cacheFrontend) {

Now call flushCache() function in a controller or model.

Explore Free Clean Cache extensions

Flushing, Enabling, and Disabling Caches in Magento 2 are necessary to every online store, because it assists the cache management process and maintains the great performance of caches. Thanks to them, the loading speed of stores’ sites will be enhanced, which helps bring customers’ experience to the next level and boost sales greatly. If you still have problems in applying these guides, just drop us a message and we will be more than happy to help.

Related Post

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service
  • magento-2-tutorial

  • cache

  • featured

Explore Our Products:

People also searched for


Stay in the know

Get special offers on the latest news from Mageplaza.

Earn $10 in reward now!

Earn $10 in reward now!

go up