I was looking for a way to clear the “template caches” and “compiled templates” from the CLI, as I want to automatically do this after every auto-deploy of the site I've created.

For this I was looking into the craft binary and its cache/list command. However, when running ./craft cache/list it only returns me cache (yii\caching\FileCache).

This felt kind of strange to me, as I was expecting a list similar to the one to be seen in the admin at the URL /admin/utilities/clear-caches:

List of possible caches, as shown in the admin

So hereby I'm wondering if it's possible to clear any of these caches show above from the CLI. Or is the cache/clear command for something else that I'm not aware of?

1 Answer 1


Craft-Scripts will do this for you: https://github.com/nystudio107/craft-scripts#clear_cachessh

You can see what it does via the source: https://github.com/nystudio107/craft-scripts/blob/master/scripts/clear_caches.sh

As for cache/clear this clear's Yii2's cache... which Craft CMS uses for almost nothing. Template Caches are always in the db, compiled templates are always cached on disk as files, and so on.

  • Thanks for the clarification. Will check out craft-scripts :)
    – Bramus
    Commented Aug 12, 2018 at 11:54

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.