Kingsfordweg 151, 1043GR Amsterdam, The Netherlands ● 24/7 support — support@novogara.com
Knowledge base

Cache invalidation

Caching is easy until the underlying data changes. Keeping a cache both fast and correct is the part that takes judgement.

Expire, invalidate or version

There are three honest approaches: let entries expire after a time, actively delete them when the source changes, or change the key when the data changes so old entries fall out of use. Each trades freshness against complexity; most systems mix them.

Time-based is simplest and often enough

A short expiry accepts brief staleness in exchange for simplicity, and for a great deal of content that is a fine deal. Reserve active invalidation for the data where even seconds of stale is wrong.

Guard against the stampede

When a popular entry expires, many requests can hit the source at once. A small lock or a staggered expiry smooths that spike — the same care as any cache under load, and it pairs well with connection pooling behind it.


Still stuck? Mail support@novogara.com — an engineer answers, at any hour. Back to the knowledge base