Bird
0
0

You want to reduce server load by caching REST API responses but also ensure data freshness. Which strategy best balances these needs?

hard📝 Application Q15 of 15
Rest API - Caching Strategies
You want to reduce server load by caching REST API responses but also ensure data freshness. Which strategy best balances these needs?
ACache responses indefinitely without validation
BSet a short cache expiration and use conditional requests with ETag headers
CDisable caching completely to always get fresh data
DOnly cache error responses to reduce load
Step-by-Step Solution
Solution:
  1. Step 1: Understand caching and freshness tradeoff

    Short cache expiration limits stale data time. Conditional requests with ETag let server confirm if data changed before sending full response.
  2. Step 2: Evaluate other options

    Disabling caching increases load. Indefinite caching causes stale data. Caching only errors doesn't reduce load effectively.
  3. Final Answer:

    Set a short cache expiration and use conditional requests with ETag headers -> Option B
  4. Quick Check:

    Short cache + ETag = freshness + load reduction = C [OK]
Quick Trick: Use short cache and ETag for freshness and efficiency [OK]
Common Mistakes:
MISTAKES
  • Disabling caching to fix freshness
  • Caching forever without validation
  • Caching only error responses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes