Skip to main content

Conditional Cacheing in Craft

by Ian Ebden in ,

Cacheing in Craft can improve performance for subsequent requests, as they will have less work to do, which is nice. Trouble is, if you're working locally the cache can sometimes get in the way – especially if you've spent the last 15 minutes trying to figure out why your changes aren't showing... er, for example.

Fear not. There's a simple solution thanks to Craft's devMode config setting. Using a cache unless tag in your templates will mean stuff will only cache on the production site, not you local or staging instances.

The more I work with Craft the more I find simple one-line solutions to everyday issues.

By the way, if you're new to Craft's {% cache %} tag be sure to thoroughly read through the docs, as cacheing is not always necessary, nor is it always the answer to performance problems.


Thanks for reading



Craft CMS Support Plans

Our support plans are ideal for Craft CMS sites that need regular updates, improvements, and someone technical keeping an eye on things.

12 years Craft experience Regular Craft and plugin updates Custom plugin development Cloud hosting Backups and 24/7 monitoring Performance audits Technical SEO Pre-booked dev time Troubleshooting

We should talk

Tell us about what you’ve got, what’s not working, and where you want to get to.

Make Contact No recruitment agencies please.