Manage cache Magento 2 using command line

Manage cache Magento 2 using command line – In Magento 2 there are 2 ways to manage cache, going to “System -> Cache Management” in backend or using command line.

You can run commands in following ways:

  • cd <your Magento install dir>/bin and run them as ./magento <command name>
  • php <your Magento install dir>/bin/magento <command name>

1. View the cache status

magento cache:status

You can get a result like this:

1 means “Enabled”  and 0 means “Disabled”

2. Enable or Disable cache types

This command enables or disables all cache types or only the ones you specify

You can get each cache type code and its description here.

 

Above commands will enable/disable all cache types. You will get the cache types status after running the command.

3. Clean and Flush cache types.

What’s different between “Clean” and “Flush”

  • Cleaning a cache type deletes all items from enabled Magento cache types only. In other words, this option does not affect other processes or applications because it cleans only the cache that Magento uses.Disabled cache types are not cleaned.
  • Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage.Flush cache types if you’ve already tried cleaning the cache and you’re still having issues that you cannot isolate.

Commands:

Please note:

magento cache:flush is equivalent “Flush Storage Cache” in System -> Cache Management

magento cache:clean is equivalent “Flush Magento Cache” in System-> Cache Management

That’s how we can manage cache Magento 2 using command line. 

Leave a Reply

Your email address will not be published.