Magento 2 Cache Management Using Magento CLI Command.
October 14, 2016 Comments 0 344 Views

Magento 2 Cache Management Using Magento CLI Command.

Magento 2 Cache can be clean or flush from the Magento admin too. But below is the method to do the same using Command Prompt Magento CLI.

Flush / Clean Magento 2 Cache CLI Command.

Get ready with the SSH details using which you can login.

Open your command prompt and login with SSH root or user.

1) SSH root@ipaddress OR SSH user@domainname.com
2) Password

After successful login visit the bin directory of magento. So if you have magento files in public_html directory then you can locate it using below command.

cd /var/www/public_html/bin

Please note that the root directory may be different as per the different hosting and server setup. So you can first get the document root from phpinfo(); and then locate the bin directory using above command in command prompt.

View Cache Status :

Once you reach the bin directory in command prompt you can enter below command to check the list of Indexers.

./magento cache:status

This command will list all the cache types available with there status. “1” in the status means the cache type is active & enable.

Magento Cache Status

Enable or Disable the cache types :

Specific cache type enable or disable. To get cache type correct name refer above list of cache status.

magento cache:enable [type]
magento cache:disable [type]

All cache type enable or disable.

magento cache:enable
magento cache:disable

This command enables you to enable or disable all cache types or only the ones you specify. Disabling cache types is useful during development because you see the results of your changes without having to flush the cache.

Cache Clean and Cache Flush :

To purge out-of-date cache from the system or while development or after installing any magento extention, you can clean or flush cache types:

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 while using clean command.

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.

Specific cache type clean or flush. To get cache type correct name refer above list of cache status.

magento cache:clean [type]
magento cache:flush [type]

All cache type clean or flush.

magento cache:clean
magento cache:flush

Magento Cache Clean

Magento Cache Flush

Below is the list of Magento Cache type with detail description :

Cache type Name Cache type Code Description
Configuration config Magento collects configuration from all modules, merges it, and saves the merged result to the cache. This cache also contains store-specific settings stored in the file system and database. Clean or flush this cache type after modifying configuration files.
Layout layout Compiled page layouts (that is, the layout components from all components).Clean or flush this cache type after modifying layout files.
Block HTML output block_html HTML page fragments per block. Clean or flush this cache type after modifying the view layer.
Collections data collections Results of database queries. If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache. Clean or flush this cache type if your custom module uses logic that results in cache entries that Magento cannot clean.
DDL db_ddl Database schema. If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache. Clean or flush this cache type after you make custom changes to the database schema. (In other words, updates that Magento does not make itself.) One way to update the database schema automatically is using the magento setup:db-schema:upgrade command.
Entity attribute value (EAV) eav Metadata related to EAV attributes (for example, store labels, links to related PHP code, attribute rendering, search settings, and so on). You should not typically need to clean or flush this cache type.
Page cache full_page Generated HTML pages. If necessary, Magento cleans up this cache automatically, but third-party developers can put any data in any segment of the cache. Clean or flush this cache type after modifying code level that affects HTML output. It’s recommended to keep this cache enabled because caching HTML improves performance significantly.
Reflection reflection Removes a dependency between the Webapi module and the Customer module.
Translations translate Merged translations from all modules.
Integration Configuration config_integration Compiled integrations. Clean or flush this cache after changing or adding integrations.
Integration API configuration config_integration_api Compiled integration APIs.
Web services configuration config_webservice Web API structure.
Previous Magento 2 Indexing Management Using Magento CLI Command
Next Remove Emoji Script & CSS from your wordpress source code.

About author

Rio
Rio 37 posts

Expert web developer working in PHP, Wordpress, Joomla, Magento, Javascript etc.

You might also like

Magento 0 Comments

Magento 2 Indexing Management Using Magento CLI Command

While working with Magento 2.1 we notice that the Re Index button was missing in Index Management ? So for the people who was using this button now have to

Magento 0 Comments

Magento 2 Admin Security Settings

Adding correct security to admin section of your Magento 2 will ensure that no unwanted login should happen in admin and your admin section will stay protected. To help and

Magento 0 Comments

Magento 2 Forgot Password Says Too many password reset requests.

Magento 2 “Forgot Password” give error to users saying ( Too many password reset requests. Please wait and try again or contact owner@example.com ) This problem generally occur when you