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

<p><code>
{% cache if not craft.config.devMode %}
</code></p>

CC BY-SA 4.0
2020-01-15T10:50:48.807Z
For Craft 3 this need to be:
{% cache if not craft.app.config.general.devMode %}
portnull
CC BY-SA 3.0
2015-07-24T14:35:43.800Z
2015-07-24T14:35:43.800Z
Ryan Shrum
<p>It is true that devMode does not turn off caching. What I do is define a flag in general.php:</p>

<pre><code>'cacheThings' =&gt; true, // true by default, but usually false for dev
</code></pre>

<p>and then in my templates:</p>

<pre><code>{% cache if craft.config.cacheThings %}
</code></pre>

<p><strong>update</strong>
Since version 2.4 there is a new config value: <a href="http://buildwithcraft.com/docs/config-settings#enableTemplateCaching" rel="nofollow">enableTemplateCaching</a>, so all you need to do now is set this <code>false</code> in your development environment.</p>

CC BY-SA 3.0
2015-04-16T10:30:25.560Z
This workaround is fine and it's good that devMode doesn't automatically disable the cache, but in my opinion there really should be a config setting for disabling the cache completely. I just added a feature request here: http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7588788-config-setting-for-cache-disabling
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-16T07:04:35.753Z
2015-07-27T06:15:22.923Z
2015-07-27T06:15:22.923Z
Marion Newlevant
<p>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?</p>

<cache>
How to disable template caching? devMode isn't doing it
# How to disable template caching? devMode isn't doing it

(Asked by: username_0 on 2015-04-16)

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?

**Tags:** cache


---

## 2 answers

### Answer by username_3 on 2015-04-16. Score: 8 | Accepted answer

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.

> **Comments:**
> **username_4**: This workaround is fine and it's good that devMode doesn't automatically disable the cache, but in my opinion there really should be a config setting for disabling the cache completely. I just added a feature request here: http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7588788-config-setting-for-cache-disabling  

---

### Answer by username_1 on 2015-07-24. Score: 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 %}`

> **Comments:**
> **username_2**: For Craft 3 this need to be: {% cache if not craft.app.config.general.devMode %}  

---

