Statamic: Relative HTML Cache Buster

Statamic’s HTML caching can really make your site fly. When a request comes in, it dumps the rendered HTML into a static file and serves that for any future requests. Simple. Easy. Lightning speed.

The problem is, it only busts the cache of the individual page or entry that’s updated and not any other page that might show that content. If you have an assortment of entries on your homepage, then you’ve most likely got some stale cache hanging around. For developers, it’s not hard to clear out the cache (although it might be a little annoying and inconvenient), but for clients, this can definitely make for a confusing and frustrating experience. The only option you really have is to ignore these pages in the cache configuration and miss out on the speed.

So we wrote a little add-on to help out with this: Statamic-relativecachebuster

Take the classic example of a blog site: You feature the latest couple of blog posts on the homepage and have an index page that lists everything. Your client creates a new post, but it’s nowhere to be found! Install relativecachebuster, and configure it to update the homepage and listing page whenever a blog post is created/edited.

 - "blog/"
 - ""

Badda-boom! Badda-bing! Those pages will be updated on the next request and you still get the speed of HTML caching.

View on Github

Happy Statamic'n!

comments powered by Disqus