Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Magento 2 Cache Cheat Sheet

Magento 2 Cache Cheat Sheet

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:flush config
Config XML bin/magento cache:flush config
JavaScript (requirejs-config.js) rm -rf pub/static/*
JavaScript (other) (none)
Uncompiled CSS (none)
LESS2 rm -rf var/view_preprocessed/*
bin/magento cache:flush full_page
Layout XML bin/magento cache:flush layout full_page
PHTML3 bin/magento cache:flush 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:flush translate full_page
PHP (constructor signature)
PHP (plugin methods)
rm -rf generated/*
bin/magento cache:flush config
PHP (collection queries) bin/magento cache:flush collections
PHP (controller for a cacheable page) bin/magento cache:flush full_page
PHP (other) (none)
Module XML (di.xml) rm -rf generated/*
bin/magento cache:flush config
Module XML (other) bin/magento cache:flush 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment