What are the cache directories of Magento 2 ?

I just need to remove those with my rm -rf command, without executing Magento cache:flush command.

4 Answers 4


Either u can manually delete folders or using this command

rm -rf var/cache/ generated/code pub/static/frontend pub/static/adminhtml

After that you need to run these commands again , else the css/styles in magento frot-end and back-end won't load

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:di:compile
sudo chmod -R 777 var/ pub/ generated/
  • After remove folder, need to run setup:upgrade! why ?
    – Pawan
    Feb 28, 2020 at 4:15

You need to remove these directories


for more information please follow this link: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/cache/partial-caching/database-caching.html


So do you want to remove cache files ? If yes, then remove these folders:



Simply remove this folders.


rm -rf var/cache/ generated/ pub/static/ var/page_cache var/view_preprocessed

  • you need to add more context to your answer, also please let us know what extra info you added in separate answer then the accepted one Apr 15 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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