Answers.Body: <p>Since the <code>{% cache %}</code> tag solely stores its information in the database, it has a guaranteed minimum of one database call to make to see if what's inside of it has already been cached.</p>
  
  <p>If you're just doing this:</p>
  
  <pre><code>{% cache %}
      Hi. I'm static text.
  {% endcache %}
  </code></pre>
  
  <p>That's quite a bit more overhead than simply:</p>
  
  <pre><code>Hi. I'm static text.
  </code></pre>
  
  <p>With no real benefit.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-08T23:22:49.403Z
Answers.Text: Does each {% cache %} tag you use query the database one time?  Or if you have several {% cache %} tags on the page, will the db only be queried once for all cached content in the db?
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-08T23:23:44.733Z
Answers.Text: Each `{% cache %}` tag queries the database *at least* one time.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-09T00:42:38.213Z
Answers.Text: There's another point here, though. Brandon in a related answer says to cache 'just those areas which involve work'. This might lead to more database calls on a page to check cache. It seems that caching static text as well as the dynamic on a page would be a win, no?
Answers.UserDisplayName: narration_sd
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-09T03:08:59.173Z
Answers.Text: @narration_sd Right - if there is a mixture of static and dynamic content in the cache tags and the dynamic part is expensive, then you might as well include the static along with it.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-09T03:37:22.017Z
Answers.Text: @BradBell, can you provide an example of a scenario where the cache tag needs to query the database more than one time?
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-09T15:53:02.657Z
Answers.Text: Database call 1: Check if items is still valid in cache. It's not. Database call 2: Save new cached item.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-08T22:34:35.503Z
Answers.LastActivityDate: 2015-02-08T22:34:35.503Z
Answers.UserDisplayName: Brad Bell
Body: <p>The Craft docs have a <a href="http://buildwithcraft.com/docs/templating/cache" rel="nofollow">good overview of the {% cache %} tag</a>.</p>
  
  <p>The docs give a couple examples of when not to use the {% cache %} tag.  In particular, they give this example:</p>
  
  <pre><code>Don’t use them to cache static text; that will be more expensive than simply outputting the text.
  </code></pre>
  
  <p>Can someone explain to me the logic behind this statement? How do the two scenarios play out where caching static text is slower than just outputting it?</p>
  
  <p>Additionally, what if you are caching a page with several queries that includes static text?  Does it follow that you'll want to cache the queries in and of themselves and let the static text remain uncached?</p>
  
Tags: <cache>
Title: Why is using the cache tag more expensive than outputting static text?
ThreadText: # Why is using the cache tag more expensive than outputting static text?
  
  (Asked by: username_0 on 2015-02-08)
  
  The Craft docs have a [good overview of the {% cache %} tag](http://buildwithcraft.com/docs/templating/cache).
  
  The docs give a couple examples of when not to use the {% cache %} tag. In particular, they give this example:
  
  ```
  Don’t use them to cache static text; that will be more expensive than simply outputting the text.
  
  ```
  
  Can someone explain to me the logic behind this statement? How do the two scenarios play out where caching static text is slower than just outputting it?
  
  Additionally, what if you are caching a page with several queries that includes static text? Does it follow that you'll want to cache the queries in and of themselves and let the static text remain uncached?
  
  **Tags:** cache
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-08. Score: 2
  
  Since the `{% cache %}` tag solely stores its information in the database, it has a guaranteed minimum of one database call to make to see if what's inside of it has already been cached.
  
  If you're just doing this:
  
  ```
  {% cache %}
      Hi. I'm static text.
  {% endcache %}
  
  ```
  
  That's quite a bit more overhead than simply:
  
  ```
  Hi. I'm static text.
  
  ```
  
  With no real benefit.
  
  > **Comments:**
  > **username_0**: Does each {% cache %} tag you use query the database one time?  Or if you have several {% cache %} tags on the page, will the db only be queried once for all cached content in the db?  
  > **username_1**: Each `{% cache %}` tag queries the database *at least* one time.  
  > **username_2**: There's another point here, though. Brandon in a related answer says to cache 'just those areas which involve work'. This might lead to more database calls on a page to check cache. It seems that caching static text as well as the dynamic on a page would be a win, no?  
  > **username_1**: @username_2 Right - if there is a mixture of static and dynamic content in the cache tags and the dynamic part is expensive, then you might as well include the static along with it.  
  > **username_0**: @username_1, can you provide an example of a scenario where the cache tag needs to query the database more than one time?  
  > **username_1**: Database call 1: Check if items is still valid in cache. It's not. Database call 2: Save new cached item.  
  
  ---
  
  