Kindly Clear Difference Between php bin/magento cache:flush and cache:clean
and when they need to Run . which tasks Output to need cache:flush or clean ** and which task need these Commands => **di:compile,setup:upgrade,setup:static-content:deploy
I consume 4 to 5 min to run cache:flush,upgrade and deploy.
Best Answer
Although question have already been answered and accepted as well, but i thought it would be nice to compile all points in single answer for better understanding and for other users who are searching for such understanding:
So we will go part by part of question(s):
Question Part A :
as @Shoib Answers, cache:flush destroys the cache storage and build cache again where as cache:clean cleans the cache and doesn't destroy the storage.
Question Part B :
when to Cache Clean ?
When you make any change in template, layout or configurations , only clean cache, you should avoid cache:flush in any case. 90% your frontend , configuration issues will be solved by cache:clean.
HINT : During frontend theme development, you can enable all caches just
disable full_page cache
, this will save you lot of time and in development, you just need to run cache:clean command.When to Cache Flush ?
Cache flush only and only , if your desired changes not worked as expected after cache:clean command.
Question Part C :
In part c of your question, you mentioned commands like :
1 - **di:compile** , 2 - **setup:upgrade** , 3 - **setup:static-content:deploy**
Let's re-order these as per usage and recommendation of commands :
1 - setup:upgrade
2 - di:compile
3 - setup:static-content:deploy
1 - setup:upgrade :
When you add new module you should run this command this command will add your module entry in setup_module table and also in config.php file. As it updates the Database schema.
2 - setup:di:compile
This command is used to create factories, proxies, interceptors etc :
in short run this command when you make any change in your module classes files, constructor etc and generates the contents of the
var/di folder in Magento <2.2
andgenerated for Magento >= 2.2
. Refer to Magento Dev Docs for complete detail3 - setup:static-content:deploy
Run this command when you are developing / making changes in your theme LESS or other JS / static files. Static view files are located in the /pub/static directory, and some are cached in the /var/view_preprocessed directory as well.
For more details about static content refer to Magento Dev Docs here and you can also read in which mode you should run which command.
Note :
If you make any change in template or layout file, php bin/magento cache:clean command will work for you , you don't need to deploy static content.
Hope this will help to understand mechanism.