3

We have a site where we use lots of {% cache %} tags.

Now we almost constantly have a "cleaning template cache" task running, and they often get stuck.

Manual DB intervention and resetting the stuck task to status pending, will sometimes make it move again.

I've tried the various solution here, but nothing helps: DeleteStaleTemplateCaches job getting stuck

Also - there are no error entries in craft.log or phperrors.log when it gets stuck.

Looking at the craft_templatecaches table I find lots of duplicate looking entries:

select id,locale, cacheKey, expiryDate, path from craft_templatecaches;

...
| 685607 | nb     | zDzBdD8bc1y4pf9Sx2HFyL3i24YypSp2sAq5 | 2015-09-08 08:23:21 | site:kompetansetilbud/ny-i-hr-rollen-i-trondheim-10013                                   |
| 685610 | nb     | TMz4eh7FPiINSUixwkpXb0SlkHnZ3b5TSgXm | 2015-09-08 08:23:22 | site:kompetansetilbud/ny-i-hr-rollen-i-trondheim-10013                                   |
| 685611 | nb     | HgLIHHgf56nM1ggOdTmaLlaylu5JeOeM1dNm | 2015-09-08 08:23:23 | site:kompetansetilbud/ny-i-hr-rollen-i-trondheim-10013                                   |
| 685612 | nb     | SLHUKfUz2fF5Jmpy0kWPpvMxFBHH8PvlVJEt | 2015-09-08 08:23:25 | site:kompetansetilbud/ny-i-hr-rollen-i-trondheim-10013                                   |
| 685614 | nb     | oEU6fe1tGc7MdI8WSQIXsf2wZZd9qmXG8P9H | 2015-09-08 08:23:26 | site:kompetansetilbud/ny-i-hr-rollen-i-trondheim-10013                                   |
...

Is this normal?

Anything else I can do to debug why the task gets stuck?


Update:

Using keyed and global caching reduced the size of the craft_templatecaches table from ~20k rows to ~300. However, this did not stop the task getting stuck.

1

As suggested by Fred, using the {% cache globally using key craft.request.path %} trick from https://craftcms.stackexchange.com/a/8335/342 gets rid of almost all duplicates!

But for the last few I notice that the duplicates all expire within seconds of each other, maybe this is an instance of https://en.wikipedia.org/wiki/Cache_stampede ?

I.e. several clients request the pages "simultaneously" and the page is rendered several times, and each version is cached?

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.