8

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?

  • 1
    You can write a command to delete the files which target multiple files to delete and use cache:flush command to clear the cache. – Nitin Pawar Nov 18 '16 at 9:25
  • What is the difference between "clean" and "flush"? – leedch Nov 18 '16 at 10:30
  • 1
    You can refer this link github.com/netz98/n98-magerun/issues/588 – Nitin Pawar Nov 18 '16 at 12:49
14

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
0

php bin/magento cache:clean : If you are 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 are 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 are 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/generation – leedch Nov 18 '16 at 10:30
  • When changing Plugins or Depency Injection on PHP Classes, you have delete var folder. – Suresh Chikani Nov 18 '16 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.