<p>There's a great article here that goes in-depth on the <code>{% cache %}</code> template tag and the pros and cons of its usage I'd suggest reading: 
<a href="https://nystudio107.com/blog/the-craft-cache-tag-in-depth" rel="nofollow noreferrer">https://nystudio107.com/blog/the-craft-cache-tag-in-depth</a></p>

<p>Template caching has pretty much remained identical to how it works in Craft 2 for Craft 3 so the article is still relevant.</p>

<p>Also worth linking to the official Craft docs on the subject: <a href="https://craftcms.com/docs/templating/cache" rel="nofollow noreferrer">https://craftcms.com/docs/templating/cache</a></p>

CC BY-SA 3.0
2018-03-19T13:18:40.270Z
Thx @Brad Bell. I already read this two articles and they helped me a lot but I still figure out how it works internally because I have failing stale template cache deletion queues but without errors in the logs. So that is the reason why I asked this question to understand better how it works and what is normal ...
Michael
CC BY-SA 3.0
2018-03-19T18:05:37.550Z
No worries... debugging stalled tasks can be difficult depending on the environment.  I assume you've seen this? https://craftcms.com/support/stuck-tasks
Brad Bell
CC BY-SA 3.0
2018-03-27T08:52:24.507Z
Thx. Yeah, I saw it already but as I haven't found any specific errors in the log I thought it doesn't apply. But today I checkt the server logs again after a task got stuck and I found the following:

`PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 286720 bytes) in /htdocs/vendor/yiisoft/yii2/db/DataReader.php on line 112`

And:
`PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 65536 bytes) in /htdocs/vendor/composer/ClassLoader.php on line 444`

Could these errors be related to the `stale template cache`?
Michael
CC BY-SA 3.0
2018-03-27T09:11:03.620Z
Okay, yeah, it seems to be the memory as the `stale template cache` entry in the `db` has almost the same timestamp as the `server logs` issues. As of the article you've posted, it could help to cut my bigger `{% cache %}` tags into pieces because the queue removes the cached elements step by step so it would be less memory heavy? Or are all cached entries removed with one big query? No, the first should apply according to the article, right?
Michael
CC BY-SA 3.0
2018-03-12T22:27:48.617Z
2018-03-12T22:27:48.617Z
Brad Bell
<p>What is the content of <code>templatecachequeries</code> table for in Craft 3? Especially the column <code>query</code>?</p>

<p>And is it normal to have a lot of entries (+5000) even on a smaller medium sized page?</p>

<p>Or it is because of badly used <code>{{% cache %}}</code> tag? How does it relate?</p>

<database><cache>
What is the table `templatecachequeries` for?
# What is the table `templatecachequeries` for?

(Asked by: username_0 on 2018-03-12)

What is the content of `templatecachequeries` table for in Craft 3? Especially the column `query`?

And is it normal to have a lot of entries (+5000) even on a smaller medium sized page?

Or it is because of badly used `{{% cache %}}` tag? How does it relate?

**Tags:** database, cache

---

## 1 answers

### Answer by username_1 on 2018-03-12. Score: 1 | Accepted answer

There's a great article here that goes in-depth on the `{% cache %}` template tag and the pros and cons of its usage I'd suggest reading:
<https://nystudio107.com/blog/the-craft-cache-tag-in-depth>

Template caching has pretty much remained identical to how it works in Craft 2 for Craft 3 so the article is still relevant.

Also worth linking to the official Craft docs on the subject: <https://craftcms.com/docs/templating/cache>

> **Comments:**
> **username_0**: Thx @Brad Bell. I already read this two articles and they helped me a lot but I still figure out how it works internally because I have failing stale template cache deletion queues but without errors in the logs. So that is the reason why I asked this question to understand better how it works and what is normal ...  
> **username_1**: No worries... debugging stalled tasks can be difficult depending on the environment.  I assume you've seen this? https://craftcms.com/support/stuck-tasks  
> **username_0**: Thx. Yeah, I saw it already but as I haven't found any specific errors in the log I thought it doesn't apply. But today I checkt the server logs again after a task got stuck and I found the following:  `PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 286720 bytes) in /htdocs/vendor/yiisoft/yii2/db/DataReader.php on line 112`  And: `PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 65536 bytes) in /htdocs/vendor/composer/ClassLoader.php on line 444`  Could these errors be related to the `stale template cache`?  
> **username_0**: Okay, yeah, it seems to be the memory as the `stale template cache` entry in the `db` has almost the same timestamp as the `server logs` issues. As of the article you've posted, it could help to cut my bigger `{% cache %}` tags into pieces because the queue removes the cached elements step by step so it would be less memory heavy? Or are all cached entries removed with one big query? No, the first should apply according to the article, right?  

---

