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?

1 Answer 1


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

  • 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
    Mar 19, 2018 at 13:18
  • No worries... debugging stalled tasks can be difficult depending on the environment. I assume you've seen this? craftcms.com/support/stuck-tasks
    – Brad Bell
    Mar 19, 2018 at 18:05
  • 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
    Mar 27, 2018 at 8:52
  • 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
    Mar 27, 2018 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.