APIs & Backend interview question

What caching strategies should you know for interviews?

Short answer

The most common is cache-aside: read from the cache, and on a miss read the database and populate the cache. Write-through updates cache and database together; write-behind writes to the cache and persists asynchronously. Every strategy needs an invalidation plan — TTLs, explicit deletes on writes, or versioned keys — and an eviction policy such as LRU.

Failure modes to discuss

  • Stale data after writes if invalidation is missed.
  • Cache stampede when a hot key expires; mitigate with locks or early refresh.
  • Cache penetration from repeated misses on keys that do not exist.
  • Cold start after a cache flush or deploy.

Where caches live

Browser and CDN caches, application in-memory caches, and shared caches such as Redis or Memcached each solve different latency problems.

How to answer it in an interview

  • Quote the classic line about cache invalidation being hard — then show a concrete plan.
  • Always state the consistency you are accepting.

Walk into your next interview prepared

Start free, install the Windows app and run a practice session today.