<p>You would wrap the code in your include in <code>cache</code> tags and use the keyword <a href="http://buildwithcraft.com/docs/templating/cache#globally" rel="nofollow"><code>globally</code></a> with it.</p>

<pre><code>{% cache globally for 3 years %}
</code></pre>

CC BY-SA 3.0
2015-02-19T16:41:30.803Z
2015-02-19T16:41:30.803Z
carlcs
<p>I have an include that is doing a DB query (it generates a menu of entries) and that's used more than once on a template.</p>

<p>Is there a way I can cache the first parse for later use to cut down on DB hits?</p>

<templating><database><performance>
Can I cache an include for use elsewhere in a template?
# Can I cache an include for use elsewhere in a template?

(Asked by: username_0 on 2015-02-19)

I have an include that is doing a DB query (it generates a menu of entries) and that's used more than once on a template.

Is there a way I can cache the first parse for later use to cut down on DB hits?

**Tags:** templating, database, performance

---

## 1 answers

### Answer by username_1 on 2015-02-19. Score: 2 | Accepted answer

You would wrap the code in your include in cache tags and use the keyword globally with it.
{% cache globally for 3 years %}


---

