Merry Christmas, 25% OFF. Coupon: XMAS Explore

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

magento-2-tutorial
cache

How to flush Cache in Magneto 2 is general topic when you guys using Magento store. Magento 2 has 12 cache types by default. There are 5 simple command to manage cache in command line. In this post I will show you step by step each command line.

I will explain cache management in this screenshot

Magento 2 Flush Cache Command Line

To flush Magento 2 cache:

  • Go to Magento root directory
  • Type: php bin/magento cache:clean and php bin/magento cache:flush
  • Finish! Go to your Magento store and check result.

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 supposed you 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

Usage:
 command [options] [arguments]

Options:
 --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
 admin:user:create                         Creates an administrator
 admin:user:unlock                         Unlock Admin Account

cache
 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 command line.

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

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, should type command line

php bin/magento cache:disable CACHE_TYPE

Example:

php bin/magento cache:disable config

Enable Cache command line

It is similar 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

Example

php bin/magento cache:enable layout

Please leave comments if you have any questions, feedbacks.

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

You also may like these Magento 2 Extensions

One Step Checkout

$199
18 reviews

Layered Navigation

$149
7 reviews

Store Locator

$199
no review

Shop By Brand

$99
no review

Zoho CRM

$249
no review

FAQ

$149
10 reviews

Better Blog

FREE
7 reviews

Affiliate

$149
7 reviews

People also searched for:

  • Magento 2 Flush Cache Command Line