# Cache Invalidation

> Clearing an old copy once the real data changes. Then no one sees old data.

**Field:** Software Development  
**Category:** Compilers & Runtimes  
**Also known as:** Invalidate Cache, Cache Busting, Stale Cache

## Think of it like

Think of it like a menu board in a cafe. When a price changes, someone must wipe the old one off.

## Definition

Cache invalidation is clearing a cached copy once the real data changes. If it is not done, people see old data, like a price that has gone up. One common way is to let copies expire after a set time. Another is to delete them when the data is saved. Getting the timing right is hard. A well-known saying calls it one of the two hard things in computer science, along with naming things.

## Example

Jack changes a product's price from 20 to 25 euros. His code deletes that product from the cache, so the next visitor sees 25 euros, not 20.

## Why it matters

A cache that is never cleared will, sooner or later, show wrong data. That can cost money and trust.

## Common mistake

Setting a long time to expire and then forgetting it. Choose it by asking how old the data may be.

## Three principles

- **Data changed.** The copy must go.
- **Expire or delete.** By time, or on save.
- **Decide how old.** Is too old.

## Related terms

- [Cache](https://learn.benibix.com/term/development/cache)
- [Memoization](https://learn.benibix.com/term/development/memoization)
- [Database](https://learn.benibix.com/term/development/database)
- [Bug](https://learn.benibix.com/term/development/bug)

---

Source: https://learn.benibix.com/term/development/cache-invalidation
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
