7

I'm trying to disable template caching in my development environment. I've tried a few things but thus far nothing has worked. I had thought that just setting devMode to true in the config would do the trick, but I'm still caching. The control panel shows the caution lines to indicate I'm in dev mode, but I still have to manually clear the cache before template changes show up. What am I overlooking?

8

It is true that devMode does not turn off caching. What I do is define a flag in general.php:

'cacheThings' => true, // true by default, but usually false for dev

and then in my templates:

{% cache if craft.config.cacheThings %}

update Since version 2.4 there is a new config value: enableTemplateCaching, so all you need to do now is set this false in your development environment.

| improve this answer | |
5

Not that creating an additional variable is that much effort, but since I only want to not cache if in devMode, I based my solution on Marion's utilizing the same devMode variable I'm using elsewhere.

{% cache if not craft.config.devMode %}

| improve this answer | |
  • For Craft 3 this need to be: {% cache if not craft.app.config.general.devMode %} – portnull Jan 15 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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