<p>As of <strong>Craft 2.4</strong>, it is now possible to use the <a href="http://buildwithcraft.com/docs/config-settings#enableTemplateCaching"><code>enableTemplateCaching</code></a> config value.</p>

<pre><code>'enableTemplateCaching' =&gt; false,
</code></pre>

<p>Simply add that to your local environment in <code>config/general.php</code>, and it'll disable the <code>cache</code> tags entirely.</p>

CC BY-SA 3.0
2015-09-30T05:28:47.677Z
2015-09-30T05:28:47.677Z
Lindsey D
<p>I found this post and the answer by @carlcs helpful.  However, I find the phrasing <code>unless not</code> in the cache logic a bit hard to wrap my head around.  I want to note here an alternative to the syntax above that I found more intuitive:</p>

<p><strong>general.php</strong></p>

<pre><code>return array(
    'live' =&gt; array(
        'cache' =&gt; true
    ),

    'local' =&gt; array(
        'cache' =&gt; false
    )
)
</code></pre>

<p><strong>cache tag which only runs in live environment</strong></p>

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

CC BY-SA 3.0
2015-03-13T18:18:10.850Z
Using `if` with the `cache` tag wasn't possible when I wrote the answer. But you're right, it reads better and I actually use it myself that way. Thanks for the reminder to change it here, too.
carlcs
CC BY-SA 3.0
2015-03-13T17:34:26.930Z
2015-03-13T17:34:26.930Z
Ben Parizek
<p>I'd prefer to use caching all the time. Since developing with caching disabled can be really confusing when something refuses to work in production with caching enabled. If you develop with caching enabled, you'd probably find issues while developing.</p>

<p>Better to clear the cache folder if you need to refresh.</p>

CC BY-SA 4.0
2018-08-06T19:44:40.253Z
2018-08-06T19:44:40.253Z
Bert Oost
<p>When working with multiple environments you most likely want to disable caching for all but one environment, because Craft saves the absolute URL to entries/assets in the cache.</p>

<p>I achieved this by setting a custom variable in general.php</p>

<pre><code>'craft.dev' =&gt; array(
    'cache' =&gt; true,
    'environmentVariables' =&gt; array(...),
)

 '192.168.178.20' =&gt; array(
    'cache' =&gt; false,
    'environmentVariables' =&gt; array(...),
)
</code></pre>

<p>and then add a conditional to the cache function in the template</p>

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

<p>With this setup I can now access the cached content on craft.dev and open the site on another devices in the network on 192.168.178.20 without having problems with cached urls.</p>

<p>I first posted this on another question about caching: <a href="https://craftcms.stackexchange.com/questions/105/what-are-the-best-practices-for-using-the-cache-tag">"What are the best practices for using the {% cache %} tag?"</a>, which might also be of interest for you!</p>

<p><em>(<strong>Edit:</strong> Since Craft 2.2 it is possible to use <code>if</code> condition with the <code>cache</code> tag, so you don't have to do messy constructs like <code>unless not</code> any more.)</em></p>

CC BY-SA 3.0
2014-07-29T07:32:10.390Z
Nice, Christian ;)
narration_sd
CC BY-SA 3.0
2014-07-02T14:11:18.453Z
2015-03-13T18:29:39.467Z
2017-04-13T12:51:00.160Z
carlcs
<p>Can I disable template caching for local development?
For example: setting a environmentVariable in a config file?
Or is this possible in the future?</p>

CC BY-SA 3.0
2014-07-02T07:14:18.627Z
Yes. See my [answer](http://craftcms.stackexchange.com/a/106/125) to this other question about caching.
carlcs
<templating><cache><multi-environment>
Can I disable template caching for local development?
# Can I disable template caching for local development?

(Asked by: username_0 on 2014-07-02)

Can I disable template caching for local development?
For example: setting a environmentVariable in a config file?
Or is this possible in the future?

**Tags:** templating, cache, multi-environment

> **Comments:**
> **username_1**: Yes. See my [answer](http://craftcms.stackexchange.com/a/106/125) to this other question about caching.  

---

## 4 answers

### Answer by username_1 on 2014-07-02. Score: 18 | Accepted answer

When working with multiple environments you most likely want to disable caching for all but one environment, because Craft saves the absolute URL to entries/assets in the cache.
I achieved this by setting a custom variable in general.php
'craft.dev' => array(
    'cache' => true,
    'environmentVariables' => array(...),
)

 '192.168.178.20' => array(
    'cache' => false,
    'environmentVariables' => array(...),
)

and then add a conditional to the cache function in the template
{% cache if craft.config.cache %}
    {# ... #}
{% endcache %}

With this setup I can now access the cached content on craft.dev and open the site on another devices in the network on 192.168.178.20 without having problems with cached urls.
I first posted this on another question about caching: "What are the best practices for using the {% cache %} tag?", which might also be of interest for you!
(Edit: Since Craft 2.2 it is possible to use if condition with the cache tag, so you don't have to do messy constructs like unless not any more.)

> **Comments:**
> **username_5**: Nice, Christian ;)  

---

### Answer by username_2 on 2015-09-30. Score: 33

As of Craft 2.4, it is now possible to use the enableTemplateCaching config value.
'enableTemplateCaching' => false,

Simply add that to your local environment in config/general.php, and it'll disable the cache tags entirely.


---

### Answer by username_3 on 2015-03-13. Score: 5

I found this post and the answer by @username_1 helpful.  However, I find the phrasing unless not in the cache logic a bit hard to wrap my head around.  I want to note here an alternative to the syntax above that I found more intuitive:
general.php
return array(
    'live' => array(
        'cache' => true
    ),

    'local' => array(
        'cache' => false
    )
)

cache tag which only runs in live environment
{% cache if craft.config.cache %}
   ...
{% endcache %}

> **Comments:**
> **username_1**: Using `if` with the `cache` tag wasn't possible when I wrote the answer. But you're right, it reads better and I actually use it myself that way. Thanks for the reminder to change it here, too.  

---

### Answer by username_4 on 2018-08-06. Score: 1

I'd prefer to use caching all the time. Since developing with caching disabled can be really confusing when something refuses to work in production with caching enabled. If you develop with caching enabled, you'd probably find issues while developing.

Better to clear the cache folder if you need to refresh.


---

