<p>I don't believe this is a valid configuration value. You will use the cache as a tag in your twig files:</p>

<pre><code>{% cache %}
    {% for element in entry.hugeField %}
        {{ element.nestedAsset.first().url }}
    {% endfor %}
{% endcache %}
</code></pre>

<p>The cache is most effective at nested queries in matrix fields or asset fields or category fields. Do not use the cache for plain text fields or those that can be accessed in linear time.</p>

<p>I would just delete that line from your <code>config.php</code></p>

CC BY-SA 4.0
2018-05-08T16:56:30.120Z
This would seem to be the case. Caching in twig is used like this throughout but this config var seems attached to nothing. Strange because in this project it uses phpdotenv and a specific env var has been created for it. Will have to double check. Thanks.
James White
CC BY-SA 4.0
2018-05-08T16:59:52.560Z
Good luck! AFAIK Craft doesn't have a "always-on" caching system, although a value such as that might be useful for disabling the cache globally.
Clark Nelson
CC BY-SA 4.0
2018-05-08T17:42:49.067Z
So digging a bit deeper, it appears to be an additional customisation when using `{% cache %}`, example: `{% cache globally using key 'someKey' if craft.config.cache %}`. That's where its coming from! Mystery solved. Not standard Craft, but I guess like you said a way to toggle caching overall.
James White
CC BY-SA 4.0
2018-05-08T22:05:14.187Z
@JamesWhite Correct, you can define arbitrary config keys and values that you can reference elsewhere (like in a template).  Probably worth linking to https://craftcms.stackexchange.com/questions/13382/what-are-the-cache-options-available-to-a-craft-installation as well
Brad Bell
CC BY-SA 4.0
2018-05-08T16:53:57.663Z
2018-05-08T16:53:57.663Z
Clark Nelson
<p>I'm reviewing the code on a project that has the following defined in the main <code>config.php</code> as a boolean:</p>

<pre><code>cache =&gt; true
</code></pre>

<p>Looking at the docs this doesn't seem to be referenced anywhere. Does the config option exist in Craft 2? I'm not seeing any documentation that states it does.</p>

<p>I know others like <code>cacheMethod</code> and <code>cacheDuration</code> do.</p>

<config>
Does the Craft config var "cache" exist?
# Does the Craft config var "cache" exist?

(Asked by: username_0 on 2018-05-08)

I'm reviewing the code on a project that has the following defined in the main config.php as a boolean:
cache => true

Looking at the docs this doesn't seem to be referenced anywhere. Does the config option exist in Craft 2? I'm not seeing any documentation that states it does.
I know others like cacheMethod and cacheDuration do.

**Tags:** config


---

## 1 answers

### Answer by username_1 on 2018-05-08. Score: 1 | Accepted answer

I don't believe this is a valid configuration value. You will use the cache as a tag in your twig files:
{% cache %}
    {% for element in entry.hugeField %}
        {{ element.nestedAsset.first().url }}
    {% endfor %}
{% endcache %}

The cache is most effective at nested queries in matrix fields or asset fields or category fields. Do not use the cache for plain text fields or those that can be accessed in linear time.
I would just delete that line from your config.php

> **Comments:**
> **username_0**: This would seem to be the case. Caching in twig is used like this throughout but this config var seems attached to nothing. Strange because in this project it uses phpdotenv and a specific env var has been created for it. Will have to double check. Thanks.  
> **username_1**: Good luck! AFAIK Craft doesn't have a "always-on" caching system, although a value such as that might be useful for disabling the cache globally.  
> **username_0**: So digging a bit deeper, it appears to be an additional customisation when using `{% cache %}`, example: `{% cache globally using key 'someKey' if craft.config.cache %}`. That's where its coming from! Mystery solved. Not standard Craft, but I guess like you said a way to toggle caching overall.  
> **username_2**: @JamesWhite Correct, you can define arbitrary config keys and values that you can reference elsewhere (like in a template).  Probably worth linking to https://craftcms.stackexchange.com/questions/13382/what-are-the-cache-options-available-to-a-craft-installation as well  

---

