Decision guide

Cache-Aside vs Read-Through vs Write-Through vs Write-Behind

Which caching pattern fits this data?

Side by side

CriterionCache-asideRead-throughWrite-throughWrite-behind
Read latency after a writeOne missOne missFast (already cached)Fast
Risk of stale dataStale-set race; bounded by TTLSame as cache-asideLow for its own writes; other writers still need invalidationDatabase lags the cache
Risk of data lossNoneNoneNoneUnflushed writes
Write path costDatabase + deleteDatabase + deleteDatabase + cache writeCache only (batched DB writes)

When to choose each

Cache-aside

The application reads the cache, loads from the database on a miss, and deletes on write.

Choose when

  • General-purpose read caching
  • Only part of the data is hot
  • You want the cache to be optional

Avoid when

  • You can't tolerate the stale-set window without leases or versions

Read-through

A cache library or service loads missing entries itself (e.g. Caffeine loaders, DAX).

Choose when

  • You want loading logic and coalescing in one place
  • In-process caches with loaders

Avoid when

  • Complex invalidation across many writers (still needs a pipeline)

Write-through

Writes update the database and then the cache in the same flow.

Choose when

  • Data that is read soon after being written
  • A single writer path

Avoid when

  • Many writers you don't control
  • Data rarely read (wastes memory)

Write-behind

Writes go to the cache and are flushed to the database later in batches.

Choose when

  • Very high write rates where loss is acceptable or recoverable (views, likes)
  • Absorbing bursts

Avoid when

  • Money, inventory or anything you can't lose
  • When you can't build durable, idempotent flushes

Verdict

Default to cache-aside (or a read-through loader) with delete-after-commit, TTLs and stampede protection. Use write-through for data read right after writing by a single writer, and write-behind only for high-volume, loss-tolerant counters with durable, idempotent flushes.

Learn more

Sources