Application and data caching.
WHERE CACHING HAPPENS
The browser A delivery network A reverse proxy The application The database layer
WHAT AN IN-MEMORY CACHE PROVIDES
Very fast storage of computed results, keyed by identifier.
WHAT IT SUITS
Expensive queries Session data Rate limiting counters Frequently read, rarely changed data
WHAT THE COMMON SOFTWARE IS
In-memory data stores supporting keys, structures, expiry and replication.
WHAT TO DECIDE PER ITEM
How long it may be stale What invalidates it
WHAT THE HARD PROBLEM IS
Invalidation.
WHAT STRATEGIES EXIST
Expiry after a period Explicit invalidation on change Versioned keys, where a change alters the key
WHAT VERSIONED KEYS AVOID
The need to delete anything.
WHAT A CACHE STAMPEDE IS
Many requests simultaneously missing and all recomputing the same value.
WHAT PREVENTS IT
Locking so one computes while others wait, or refreshing before expiry.
WHAT TO MONITOR
Hit rate, memory use, and eviction rate.
WHAT HIGH EVICTION INDICATES
Insufficient memory for the working set.