Skip to content
Networking Lab · LAB-06Under investigation

“Adding a cache always makes it faster.”

A cache with a poor hit rate adds a lookup, a write, an eviction policy and an invalidation bug, in exchange for very little.

Verdict
IT DEPENDS
Level
SYSTEMS
Division
LAB-06
References
02

Investigation

Cache benefit is roughly hit_rate × saved_cost − overhead. At a 10% hit rate on an operation that was already fast, the overhead dominates. Worse, a cache changes the failure mode: instead of being slow, the system is now occasionally wrong, and wrong is harder to notice.

FailureSymptom
Stale entryUsers see old data; the bug is invisible in staging
Cache stampedeThe entry expires under load and every request rebuilds it at once
Key collisionOne user sees another user's data, a cache bug that is a security incident
Unbounded growthMemory rises until something is evicted or something dies
Cached errorA 500 is stored and served happily for an hour

References

  1. 01MDNHTTP caching
  2. 02web.devPrevent unnecessary network requests with the HTTP Cache