3

Is it common to have a (near)constantly running 'Deleting stale template caches' task ongoing? I commonly log in to see a task still pending several hours after the last change to the site was made, looking in the database the task usually has 50000+ 'steps'. Each step runs reasonably quickly (although it sometimes hangs) but the process appears to be taking up quite a lot of disk IO according to newrelic and clearly some pages are not getting their cache cleared for quite some time...

What could cause this and it it solvable?

If it's any help I have a reasonably large dynamic menu that i've put in 'cache' tags around and also have one channel with >1200 entries in it and the site is in 5 languages (although the channel with 1200 entries isn't localised) so this isn't a tiny site, performance still seems sluggish at times however.

8

The {% cache %}, by default will cache it's contents on a per URL and per locale basis.

A lot of times when we see the behavior you're seeing, that's not the desired behavior and you should be using the {% cache globally %} parameter, where Craft stores the cached segment only on a per locale basis and drastically reduces the number of rows in the database table.

I'd inspect everywhere you're using the tag and if it makes sense to use globally parameter, swap to that.

You can then clear the contents of your template cache tables (under Settings->Tools->Clear Caches Tool) and the database tables shouldn't grow anywhere near as large, letting the delete stale template caches task run faster.

  • Awesome thanks Brad! – Darren Aug 22 '14 at 17:39

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.