Magento – Magento 2 – Very slow performance, Cache/static files issues after disabling cache and flushing static files cache

cachemagento-2.1.3magento2performance

Today is my first day using Magento 2 (I know Magento 1).

I'm running Magento 2.1.3 locally on MAMP, PHP v 7.0.13.

I had installed Magento 2, I was trying out creating a new theme, and the site was running OK.

I was trying to switch the parent theme and not seeing expected results, so I (naively):

  • 1) disabled the Cache
  • 2) flushed Static Files cache.

I did this in the Cache Management admin area. I didn't realize all hell was going to break loose when I did this…

Since then, I can barely load pages. I could see files were being generated to pub/static. This has been happening for about an hour and a half.

When I did this, Magento was in default mode. I've now switched to developer mode (about 20 minutes ago) as per "Set the Magento mode":http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-mode.html

rm -rf <your Magento install dir>/var/di/* <your Magento install dir>/var/generation/*
magento deploy:mode:set developer

…but I'm still waiting for minutes (like 10 minutes or more) for pages to load, it's just absolutely crawling. It seems like the page renders but it doesn't finish loading and there are JS issues (I can't use the admin menu, etc.) I also can't see icons like the cart icon, menu icons…

I thought the site was not dependendent on pub/static when in developer mode? Static files still seem to be being generated in pub/static (on the fly??)

I'm on a Macbook Air with 8GB memory, 1.7 GHz Intel Core i7, and the fans going crazy, CPU is maxed out. Running Magento 1 was possible, although sometimes slow, but never this slow!

I have also tried to enable/disable Caches and enabling caches makes things faster. But surely (like Magento 1) while developing, it makes sense to keep caches disabled?

Any suggestions? Do I just need to wait and have more patience?

Thank you.

Best Answer

From my experience:

When working with Magento 2 (especially on your local machine), you need to enable Cache. Using command line to clean or flush cache if you want to see your new change.

For the static contents(js, html templates) under pub/static, you can edit directly the file to see the new changes. Need to disable or clear Browser Cache also. If still not see the changes, try to clear Magento Cache. If it works, copy it to the "real" file in your module.

You should set the mode to developer mode during development, because, you will don't need to run di compile again and again.

Related Topic