Caching as a trade-off
A cache keeps a reusable copy near a requester so repeated work can be avoided, at the cost of managing freshness.
Learning objectives
- Define cache hit, miss, freshness, and invalidation.
- Describe one cache policy and its trade-off.
Request flow
request → cache lookup → hit: return cached value
→ miss: read origin, store copy, return valueA hit can reduce latency and origin load. A miss still needs the original source. The difficult question is not “should we cache?” but “when is a copy acceptable and how is it refreshed or invalidated?”
Policy example
A course title that changes rarely can use a time-to-live so copies expire after a short period. A changing enrollment balance may require a tighter consistency strategy. The appropriate choice depends on the harm caused by stale data, load, and operational complexity.
Common mistakes
- A cache does not replace the authoritative data source.
- Do not assume cache invalidation is automatic; define who changes or expires entries.