Write-Through vs Write-Back Cache: Differences Explained
A write policy decides what happens when the CPU writes to data that is in the cache. A write-through cache updates the cache and main memory at the same time, so memory is always current but every write costs memory traffic. A write-back cache updates only the cache, marks the line dirty, and writes it to memory later when the line is evicted. Write-back is faster and uses less bandwidth, but it is more complex to keep consistent.
| Aspect | Write-through | Write-back |
|---|---|---|
| Write policy | Every write goes to both the cache and the next memory level | A write updates only the cache and sets the dirty bit; memory is updated on eviction |
| Memory traffic | High: every write goes out | Lower: repeated writes to one line are merged into one write-back |
| Write speed | Slower without help; a write buffer hides much of the delay | Faster: writes complete at cache speed |
| Consistency with memory | Memory is always up to date, which simplifies sharing with DMA and other cores | Memory can be stale until the line is written back, so coherence needs more care |
| Complexity | Simple | More complex: dirty bits, write-back on eviction, coherence protocols |
| Cost of eviction | Cheap: nothing needs to be written | Evicting a dirty line costs an extra write to memory |
| Usual write-miss policy | No-write-allocate | Write-allocate |
| Typical use | Some L1 caches and simple or reliability-focused systems | Most modern CPU caches, especially L2 and L3 |
Figures are typical orders of magnitude and vary by process generation and product.