<p>The reason the documentation says to not use it on static text, is because the cached data will be saved to the database, resulting in at least one database query (two if it needs to update the data). Database operations are fairly expensive compared to reading data from files, or running twig code, so in many cases this will be slower than just showing the text.</p>

<p>There's no way to know for sure if using <code>cache</code> tags will be a benefit in your case. It really depends on what exactly you're doing in your template, and where the bottlenecks in your system is. The only way to know, is to test it. If you <a href="http://buildwithcraft.com/docs/config-settings#devMode" rel="nofollow">turn devMode on</a>, reload your page with and without the <code>cache</code> tag enabled, you could compare the response time shown in the console output under "Profiling Summary Report". This is the time it takes for the page to be generated by craft, which is what you'd seek to minimize using the <code>cache</code> tag. Remember to reload the page several times for each case and do an average, since the result will vary somewhat depending on what else is going on in your system.</p>

CC BY-SA 3.0
2015-04-06T10:21:54.373Z
Yes, indeed. The test showed up, that using `cache` tags on data pulled from within the file, has increased the size of transferred data from server. So What I've learned, is to use `cache` tags on parts of code, where database queries is performed only.
Dominik Krulak
CC BY-SA 3.0
2015-04-06T19:04:19.467Z
@Dominik ...and/or if you do anything which is computationally really taxing in your template, such as looping through a serious number of objects, merging large arrays within loops, complex string manipulations etc. Like André says, when in doubt check your profiling :)
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-04-06T09:57:03.523Z
2015-04-06T09:57:03.523Z
André Elvan
<p>I've read <a href="http://buildwithcraft.com/docs/templating/cache#when-to-use-cache-tags" rel="nofollow">documentation</a> and it says, that We shouldn't use cache tags on static text.</p>

<p>I have a files, that are static in that way, that the data are pulled from within a file, or in some case, data are pulled from outside a file, where <code>cache</code> tags are.</p>

<p>For example - language and territory data, static navigation.</p>

<p>Within <code>cache</code> tags I have pretty computationally statements and looping, where documentation says, that it's exception.</p>

<cache>
Should I use cache on data pulled from within files?
# Should I use cache on data pulled from within files?

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

I've read [documentation](http://buildwithcraft.com/docs/templating/cache#when-to-use-cache-tags) and it says, that We shouldn't use cache tags on static text.

I have a files, that are static in that way, that the data are pulled from within a file, or in some case, data are pulled from outside a file, where `cache` tags are.

For example - language and territory data, static navigation.

Within `cache` tags I have pretty computationally statements and looping, where documentation says, that it's exception.

**Tags:** cache


---

## 1 answers

### Answer by username_1 on 2015-04-06. Score: 3 | Accepted answer

The reason the documentation says to not use it on static text, is because the cached data will be saved to the database, resulting in at least one database query (two if it needs to update the data). Database operations are fairly expensive compared to reading data from files, or running twig code, so in many cases this will be slower than just showing the text.

There's no way to know for sure if using `cache` tags will be a benefit in your case. It really depends on what exactly you're doing in your template, and where the bottlenecks in your system is. The only way to know, is to test it. If you [turn devMode on](http://buildwithcraft.com/docs/config-settings#devMode), reload your page with and without the `cache` tag enabled, you could compare the response time shown in the console output under "Profiling Summary Report". This is the time it takes for the page to be generated by craft, which is what you'd seek to minimize using the `cache` tag. Remember to reload the page several times for each case and do an average, since the result will vary somewhat depending on what else is going on in your system.

> **Comments:**
> **username_0**: Yes, indeed. The test showed up, that using `cache` tags on data pulled from within the file, has increased the size of transferred data from server. So What I've learned, is to use `cache` tags on parts of code, where database queries is performed only.  
> **username_2**: @Dominik ...and/or if you do anything which is computationally really taxing in your template, such as looping through a serious number of objects, merging large arrays within loops, complex string manipulations etc. Like André says, when in doubt check your profiling :)  

---

