QamoosTech
Architecture & DesignScaling and performanceIntermediate

Write-Through Cache

PronunciationRYT-throo KASH

Definition

In a write-through cache every write goes to the cache and the database together, so reads from the cache are never stale. A write-back cache writes to the cache first and saves to the database later.

Where you hear it

In caching strategy discussions, storage controllers, and ORM or CDN settings.

Examples

  • Write-through keeps reads fast and correct, but each write is slower.
  • Write-back risks losing data if the cache dies before it flushes.
  • The write-through cache updates the database and the cache in the same request.

Common mistake

Choosing write-back for important data. If the cache fails before saving, the data is gone.

Don't confuse with

Cache-aside, where the application fills the cache on reads instead of on every write.

Say it at work

  • In a meeting or chatWe use write-through for the settings table.
  • In an email or ticketWhat happens on a crash with write-back?