The term static view file refers to the following:
- “Static” means it can be cached for a site (that is, the file is not dynamically generated). Examples include images and CSS generated from LESS.
- “View” refers to presentation layer (from MVC).
Static view files are located in the <your Magento install dir>/pub/static
directory, and some are cached in the <your Magento install dir>/var/view_preprocessed
directory as well.
- Developer mode: Magento generates them on demand, but the rest are cached in a file for speed of access.
- Default and production modes: Static files are not generated or cached.
Developer mode only: When you install or enable a new module, it might load new JavaScript, CSS, layouts, and so on. To avoid issues with static files, you must clean the old files to make sure you get all the changes for the new module.
You can clean generated static view files in any of the following ways:
- Manually by clearing the
pub/static
andvar/view_preprocessed
directories and subdirectories. except forpub/static/.htaccess
.To clear the
pub/static
directory of all files except.htaccess
, enter the following command:
find . -depth -name .htaccess -prune -o -delete
- Using the Magento command line. Several commands support an optional parameter
--clear-static-content
, which cleansgenerated static view files. For example, see Enable or disable modules.
In the Magento Admin. Go to System > Tools > Cache Management and click Flush Static Files Cache.
Deploy static view files
magento setup:static-content:deploy <lang> ... <lang> [--dry-run]