Skill Zuno · skillzunos.com · System Design
Caching interview questions
Prepare for Caching interviews on Skill Zuno. This practice book covers Caching interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.
Open Caching on Skill ZunoAlso see the Caching tutorial.
Caching stores copies of frequently used data in a faster layer, such as memory, a CDN or the browser, to cut latency and load on databases. The hard parts are deciding what to cache, keeping it fresh and handling failures. Interviews cover caching strategies, eviction policies, invalidation, cache stampedes and where caches sit in an architecture.
Sample Caching interview questions
What is the cache-aside pattern?
The application checks the cache first. On a miss it reads from the database, stores the result in the cache and returns it. On a write it updates the database and deletes the cache entry.
What is the difference between write-through and write-back caching?
Write-through writes to the cache and database together, so data is safe but writes are slower. Write-back writes to the cache and flushes to the database later, which is fast but can lose data if the cache fails.
What is a cache stampede and how do you prevent it?
When a popular entry expires, many requests miss at once and all hit the database. Prevent it with a lock so only one request rebuilds the entry, by refreshing early, or by adding random jitter to TTLs.
Why delete the cache entry on write instead of updating it?
Two concurrent writers can update the cache in a different order from the database and leave stale data. Deleting the entry means the next read loads the current value.
What should not be cached?
Data that changes on almost every request, data that must always be exactly current such as account balances during a transfer, and per-user data with a very low hit ratio.
What you can practice
- Caching interview questions for beginners and experienced developers
- Level-based practice: New, Easy, Medium, Hard, and Diff
- System Design topics alongside Caching on skillzunos.com