Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Caching Strategies
STORAGE, CACHING & SEARCH · SUBTOPIC

Cache-Aside, Write-Through & Write-Back

Compare the three core read/write caching strategies and when to pick each.

BeginnerPart of Caching Strategies
Practice in AI HLD
Subtopics in Caching Strategies (2)
OverviewCaching PatternsStampede & Failures

In plain words

Cache-aside checks your pocket first and only goes to the filing cabinet if it’s missing. Write-through updates both pocket and cabinet together. Write-back scribbles in your pocket and files it later.

Think of it like…

Keeping frequently used ingredients on the kitchen counter (Cache-Aside) vs. updating inventory books on every scoop (Write-Through).

Loading interactive diagram
Loading interactive exercise

Theory & how it works

How to update or invalidate on writes in Cache-Aside

When data changes in the DB, delete the cache key (DEL user:42) rather than writing the new value blindly - deleting avoids race conditions where two concurrent writers overwrite the cache in the wrong order.

Key points & practical guide

Summary checklist

  • Cache-Aside is the default for 80% of apps
  • Delete cache key on update rather than blind overwrite
  • Never use Write-Back without persistence/AOF if data loss is unacceptable

When to use it

  • Read-heavy services
  • Expensive computed responses or DB aggregations

Watch out for

  • Not setting a TTL - stale or unused data fills RAM forever

Quick check

Loading quiz
Parent topic
Caching Strategies
Next subtopic
Cache Stampede, Penetration & Avalanche