Interview › Databases & Caching
How do you decide what to cache and what not to cache?
Databases & Caching · Advanced level
Answer
I cache data that is frequently read, expensive to fetch or compute, reasonably small, and tolerant of staleness. I avoid caching rapidly changing, sensitive, authorization-heavy, cheap, or strict-consistency data.
Technical explanation
Good cache candidates are hot, expensive, small, and stale-tolerant.
Bad candidates are rapidly changing, sensitive, huge, cheap to query, or strict-consistency data.
Authorization-heavy data requires special care because stale permissions are a security risk.
Hands-on example
Decision examples:
Cache product category list: yes.
Cache payment balance: no, read primary.
Cache user permissions for 1 hour: risky; prefer short TTL or token/revocation design.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- How do you handle cache warming after a restart or failover?
- What is the blast radius of a cache outage, and how do you make the app degrade gracefully?
- How do you test a Redis or database failover without impacting users?
- How would you use Redis for distributed locking, and what are the caveats?
- How would you use Redis for rate limiting?
- What is the difference between Redis as a cache and Redis as a primary datastore?
- Why are some Redis commands (KEYS, FLUSHALL) dangerous in production?
- What is a cache hit ratio, and how do you improve it?