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?

up vote 2 down vote accepted

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 Aug 12 at 11:54

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.