Directory and cache clearing
While you're developing components (modules, themes, and language packages), your rapidly changing environment requires you to periodically clear certain directories and caches. Otherwise, your code runs with exceptions and won't function properly.
This topic provides guidelines on what directories to clear and when to clear them. All directories discussed in this topic are default locations. It's possible to customize these locations but doing so is beyond the scope of this topic.
When you're developing components (modules, themes, and language packages), the following directories contain temporary or generated files you can clear periodically:
generated/codegenerated/metadatapub/staticjs and html files for each store view.var/cachevar/composer_homevar/page_cachevar/view_preprocessedWhat directories to clear
The following table provides guidelines on what you should clear and when.
generated/metadata, generated/codegenerated/metadata, generated/codedi.xmlgenerated/metadata, generated/code (also need to run the code compiler again)generated/metadata, generated/code, var/cache, var/page_cachevar/view_preprocessed, var/cache, var/page_cachevar/view_preprocessed, var/cache, var/page_cache, pub/static*.js or *.html filespub/staticvar/cache, var/page_cacheHow to clear the directories
To only clear directories and not perform other actions, log in to the application server as the file system owner and clear directories using a command like the following:
rm -r <magento_root>/generated/*/*
You can also use the following command-line tools clear some directories for you. These commands perform other tasks as well; consult the linked documentation for more details.
developer and production modegenerated/metadata, generated/code, var/view_preprocessed