This page lists what caches or directories you will need to clear to apply various types of changes. It is consolidated and adapted from the complete official documentation on directories and caches.
๐ If your development environment supports it, you are better off using Vinai's automatic cache cleaner. As of this writing, the primary reason why it might not work is if your code is hosted on a NFS share (common with Vagrant).
Generally you will only need to clear caches on the server side. Browser caches shouldn't need to be cleared by default, unless you manually turn off Magento 2's built-in cache busting feature.
These instructions assume that you have all caches enabled and are in development mode. Note that if you are working heavily in a specific area, it often makes sense to disable the relevant caches.
NOTE: This cheat sheet does not yet cover caches related to Magento REST/SOAP APIs.
Type of Change | Action Needed |
---|---|
Admin Settings1 | bin/magento cache:clean config |
Config XML GraphQL Schema Changes |
bin/magento cache:clean config |
JavaScript (requirejs-config.js) | rm -rf pub/static/* |
JavaScript (other) | (none) |
Uncompiled CSS | (none) |
LESS2 | rm -rf var/view_preprocessed/* bin/magento cache:clean full_page |
Layout XML | bin/magento cache:clean layout full_page |
PHTML3 | bin/magento cache:clean block_html full_page |
Knockout HTML Template (newly overridden) | rm -rf pub/static/* |
Knockout HTML Template (change to in-use version) | (none) |
Translation CSV | bin/magento cache:clean translate full_page |
PHP (constructor signature) PHP (plugin methods) |
rm -rf generated/* bin/magento cache:clean config |
PHP (collection queries) | bin/magento cache:clean collections |
PHP (controller for a cacheable page) | bin/magento cache:clean full_page |
PHP (other) | (none) |
Module XML (di.xml) | rm -rf generated/* bin/magento cache:clean config |
Module XML (other) | bin/magento cache:clean config |
1 This is a minimal need. If the setting affects other functionality, other caches may need to be cleared.
2 If setup:static-content:deploy
has been run, then you will also need to run rm -rf pub/static/*
. (Running that command is not recommended in developer mode, however; it is intended for production deploys.)
3 Neither block_html
nor full_page
is always necessary to be cleared, but the distinction will depend on the particular block and page being modified, so this is a safe general rule.
@scottsb one other suggestion...can you switch
cache:flush
tocache:clean
in all the examples?cache:flush <TYPE>
isn't really a thing in practice. With Redis, for example, it will wind up doingFLUSHDB
even if you docache:flush <TYPE>
, so it's the same as just flushing the entire cacheSee: magento/magento2#26020
This can be confirmed using
redis-cli MONITOR
and testing the commands that get issued withcache:clean <TYPE>