← All articles

System Design

Cache Invalidation: A System Design Checklist

Questions to answer before a cache becomes part of a critical request path.

1 min read
RedisDatabasesSystem DesignArchitecture

The hard part of caching is deciding what happens when the source data changes. Design that path before optimizing the read path.

Define ownership

One service should own updates to the source of truth. It should also define the event or action that invalidates cached representations.

Pick an invalidation strategy

Common choices include expiration, explicit deletion on write, and event-driven invalidation. Each option trades freshness, complexity, and operational visibility differently.

Invalidation is major decision when you implement caching. Invalidation can be rquired for following reasons:

  1. When you dont have enough memory left to keep cache.
  2. when data in cache is stale data.
  3. The TTL is expired for any cached data.

If data not removed from cache, then it can effect the performance of the application as well.

Make stale data safe

Not every field has the same freshness requirement. Keep safety-critical values out of a cache or use a deliberately short lifetime.

Related articles