Bird
0
0

You want to design a cache invalidation strategy for a REST API where data changes frequently but must stay fresh within 5 minutes. Which combined strategy is best?

hard📝 Application Q15 of 15
Rest API - Caching Strategies
You want to design a cache invalidation strategy for a REST API where data changes frequently but must stay fresh within 5 minutes. Which combined strategy is best?
AUse time-based invalidation with 5-minute expiry plus event-based invalidation on data changes
BUse manual invalidation only, requiring user to clear cache
CUse versioning only without time limits
DUse time-based invalidation with 1-hour expiry only
Step-by-Step Solution
Solution:
  1. Step 1: Analyze freshness requirement

    Data must be fresh within 5 minutes, so time-based expiry should be 5 minutes or less.
  2. Step 2: Combine with event-based invalidation

    Event-based invalidation clears cache immediately on data changes, improving freshness.
  3. Step 3: Evaluate other options

    Manual invalidation is slow, versioning alone may keep stale data, and 1-hour expiry is too long.
  4. Final Answer:

    Use time-based invalidation with 5-minute expiry plus event-based invalidation on data changes -> Option A
  5. Quick Check:

    Combine time and event for fresh cache [OK]
Quick Trick: Combine time and event for best freshness [OK]
Common Mistakes:
MISTAKES
  • Relying only on manual invalidation
  • Using too long expiry times
  • Ignoring event triggers for changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes