<p>So you're accessing <code>craft.config.cache</code> but unless you've actually added your own <code>cache</code> config setting in <code>craft/config/general.php</code> that's not going to work. There's no <code>cache</code> setting in Craft's <a href="https://craftcms.com/docs/config-settings" rel="nofollow noreferrer">Config Settings</a></p>

<p>So the reason it works on <code>live</code> production is it's a soft error, and you have <code>devMode</code> off, so it continues to work. In <code>local</code> dev, presumably you have <code>devMode</code> on, so it rightly errors.</p>

<p>For more information on Craft cache tags, you can read the <a href="https://nystudio107.com/blog/the-craft-cache-tag-in-depth" rel="nofollow noreferrer">The Craft {% cache %} Tag In-Depth</a> article.</p>

CC BY-SA 3.0
2017-11-22T04:00:56.450Z
2017-11-22T04:00:56.450Z
andrew.welch
<p>Have you tried to activate development mode under <code>craft/config/general.php</code>?</p>

CC BY-SA 3.0
2017-08-23T21:32:41.320Z
2017-08-23T21:32:41.320Z
Jefry Dewangga
<p>I'm having an issue where I am getting template errors related to my craft cache tags in some environments but not others. I have my site set up on a production server that is a Linode/Forge setup. The site works fine there.</p>

<p>Locally I am using a Homestead/Vagrant setup and I am getting template errors on any pages that use the cache tag.</p>

<p>Here's the code that is having the error:</p>

<pre><code>{% extends "_layout" %}


{% block pageStyles %}

{% for entry in craft.entries.section('juices') %}
    .color-nameplate.btn-{{entry.slug}} {
        background-color: {{entry.productColorCode}};
    }
{% endfor %}

{% endblock %}

{% block bodyClass %}home-page{% endblock %}


{% block content %}

{% cache if craft.config.cache %}

{% for row in entry.bodyBuilder.level(1) %}
    {% include 'bodyblocks/' ~ row.type.handle with {row: row} %}
{% endfor %}

{% endcache %}

{% endblock %}
</code></pre>

<p>This code works in the production environment but not on local. On local it is showing the following template error:</p>

<blockquote>
  <p>Unexpected token "name" of value "craft" ("end of statement block" expected).</p>
</blockquote>

<p>If I remove the cache tags then the template displays, but this won't work for my production environment so I need to work out what the issue is. </p>

<p>Thanks,</p>

<p>Brian</p>

<cache>
Getting Template Errors When Using Cache Tag in some environments but not in others
# Getting Template Errors When Using Cache Tag in some environments but not in others

(Asked by: username_0 on 2017-08-17)

I'm having an issue where I am getting template errors related to my craft cache tags in some environments but not others. I have my site set up on a production server that is a Linode/Forge setup. The site works fine there.
Locally I am using a Homestead/Vagrant setup and I am getting template errors on any pages that use the cache tag.
Here's the code that is having the error:
{% extends "_layout" %}


{% block pageStyles %}

{% for entry in craft.entries.section('juices') %}
    .color-nameplate.btn-{{entry.slug}} {
        background-color: {{entry.productColorCode}};
    }
{% endfor %}

{% endblock %}

{% block bodyClass %}home-page{% endblock %}


{% block content %}

{% cache if craft.config.cache %}

{% for row in entry.bodyBuilder.level(1) %}
    {% include 'bodyblocks/' ~ row.type.handle with {row: row} %}
{% endfor %}

{% endcache %}

{% endblock %}

This code works in the production environment but not on local. On local it is showing the following template error:

Unexpected token "name" of value "craft" ("end of statement block" expected).

If I remove the cache tags then the template displays, but this won't work for my production environment so I need to work out what the issue is. 
Thanks,
Brian

**Tags:** cache

---

## 2 answers

### Answer by username_1 on 2017-11-22. Score: 2

So you're accessing `craft.config.cache` but unless you've actually added your own `cache` config setting in `craft/config/general.php` that's not going to work. There's no `cache` setting in Craft's [Config Settings](https://craftcms.com/docs/config-settings)

So the reason it works on `live` production is it's a soft error, and you have `devMode` off, so it continues to work. In `local` dev, presumably you have `devMode` on, so it rightly errors.

For more information on Craft cache tags, you can read the [The Craft {% cache %} Tag In-Depth](https://nystudio107.com/blog/the-craft-cache-tag-in-depth) article.


---

### Answer by username_2 on 2017-08-23. Score: 0

Have you tried to activate development mode under `craft/config/general.php`?


---

