InterviewBuddy
All interview questions

When would you add a cache?

Beginner

Answer

Add a cache when repeated reads or expensive computation are a measured bottleneck and the application can tolerate a defined freshness policy. Decide keys, expiry, invalidation, and failure behavior.

Explanation

A cache introduces consistency and operational tradeoffs. Protect against stampedes and avoid sharing personalized data under a common key.

Example

Request → cache hit: return
        → cache miss: database → populate cache