I'm having a hard time in development with generated classes, pre-processed files and caches in Magento2.
In comparisson with Magento1 it seems no longer possible to efficiently develop when disabling all caches, plus I also need to see if caches interfere with features I build.
My problem is, that there are so many caches and generated files, I'm not sure which are dependent of each other and in what sequence I should flush them in order to get a fresh view of all my developments.
There's the Backend Cache area
- All the standard caches that can be cleaned
- The Catalog image cache
- The Static Files cache
- The CSS/JS Cache
Then there is the bash commands
- php bin/magento cache:clean
- php bin/magento setup:static-content:deploy
Then there folders you can manually delete
- var/generation
- var/cache
- var/page_cache
- var/view_preprocessed
- pub/static
That's a lot of possibilities and probably not all. So if I deploy a large update, Code Changes, CSS/JS changes, Template changes
Which of these steps should I do to get everything cleaned? In what sequence must these steps be done?
2 Answers 2
Normaly you don't have to clear the folder manually. I use the following "rotation"
For clearing the cache:
- bin/magento cache:clean
For reindex new xml files:
- bin/magento index:reindex
- List item
- bin/magento cache:clean
For refresh or insert new plugins:
- bin/magento setup:upgrade
- -d memory_limit=-1 bin/magento setup:static-content:deploy de_DE
- bin/magento index:reindex
- bin/magento cache:clean
If you need a "full-cleanup/refresh":
- bin/magento setup:upgrade
- -d memory_limit=-1 bin/magento setup:di:compile
- -d memory_limit=-1 bin/magento setup:static-content:deploy de_DE
- bin/magento index:reindex
- bin/magento cache:clean
php bin/magento cache:clean - If you change .phtml files code and cache enable from admin then you have to use of it.
php bin/magento setup:static-content:deploy - If you change CSS, JS or .html files code then you have to use of it. These files are located in web folder.
Var folder delete manually - If you change Block, Controller, Model etc .PHP file code then you have to delete manually first var folder.
Use of these commands you can see your change.
- 
 - php bin/magento setup:static-content:deploy Seems to require me to click the "Flush Static Files Cache" Button, otherwise I wait for about 5min for the generation and it still doesn't work When changing Plugins or Depency Injection on PHP Classes, it seems to me that it only works when I flush the directory var/generationleedch– leedch2016年11月18日 10:30:55 +00:00Commented Nov 18, 2016 at 10:30
- 
 When changing Plugins or Depency Injection on PHP Classes, you have delete var folder.Suresh Chikani– Suresh Chikani2016年11月18日 10:52:44 +00:00Commented Nov 18, 2016 at 10:52
- 
 When changing Plugins or Depency Injection on PHP Classes, you have to run "php bin/magento setup:di:compile" onlyGohil Rajesh– Gohil Rajesh2021年09月22日 04:45:57 +00:00Commented Sep 22, 2021 at 4:45
cache:flushcommand to clear the cache.