Achieving a high hit rate is important, and in the first couple of chapters of the book, we focused on that for obvious reasons.
But as you start aggressively caching content, you’ll end up in situations where important content updates need to become visible. Waiting for the TTL to expire is not an option.
Remember the saying from the start of this chapter:
There’s only one thing worse than not caching enough, and that is caching for too long.
Thanks to the various cache invalidation mechanisms that Varnish offers, you can customize the way you want to evict objects from the cache.
Here we mean mechanisms like simple purges, regular expression patterns used for bans, and even tag-based invalidation using secondary keys.
Varnish has got you covered, and VCL will allow you to implement
invalidation the way you want. But even without VCL, you can ban
content from the cache: varnishadm allows direct interaction with the
ban list.
And for those who don’t want to depend on VCL, and want to remotely ban content, you can still use the CLI protocol.
A lot of options, a lot of potential integrations: choose wisely, and integrate cache invalidation into your application, so that you never face a situation where breaking news doesn’t break at all.