← Lessons

quiz vs the machine

Gold1400

System Design

The Negative Caching

Caching the fact that something does not exist to stop repeated useless lookups.

4 min read · core · beat Gold to climb

What it is

Negative caching stores the result that a key has no value, such as a not found or an empty response. Without it, every request for a missing key becomes a full database lookup that returns nothing, wasting backend capacity on repeated dead ends.

Why it matters

  • It blocks floods of lookups for keys that simply do not exist.
  • It defends against cache penetration, where attackers request random nonexistent keys to bypass the cache and hammer the database.
  • It turns an expensive miss into a cheap cached negative result.

The catch

A negative entry can go stale if the key is later created. Negatives should use a short TTL so a newly added value appears quickly, and creation paths should invalidate any negative entry for that key.

Key idea

Negative caching remembers that a key is absent so repeated misses stay cheap, using short TTLs to avoid hiding data that is later created.

Check yourself

Answer to earn rating on the learn ladder.

1. What does negative caching store?

2. Why should negative entries use a short TTL?