Bird
0
0

You want to optimize a REST API to reduce bandwidth by sending full data only when it changes. Which combination of headers should you use in the response?

hard📝 Application Q15 of 15
Rest API - Request and Response Format
You want to optimize a REST API to reduce bandwidth by sending full data only when it changes. Which combination of headers should you use in the response?
ACache-Control: max-age=0 and no ETag
BCache-Control: no-cache and ETag with unique value
CCache-Control: no-store and no ETag
DCache-Control: max-age=3600 and no ETag
Step-by-Step Solution
Solution:
  1. Step 1: Identify headers that enable conditional requests

    ETag provides a unique identifier for content versions, allowing clients to ask if content changed.
  2. Step 2: Understand Cache-Control no-cache directive

    no-cache forces the browser to validate with the server before using cached data, ensuring fresh content without unnecessary full data transfer.
  3. Step 3: Evaluate other options

    Options without ETag cannot validate changes efficiently; no-store disables caching; max-age=0 without ETag disables validation.
  4. Final Answer:

    Cache-Control: no-cache and ETag with unique value -> Option B
  5. Quick Check:

    no-cache + ETag = bandwidth saving [OK]
Quick Trick: Use no-cache with ETag for efficient validation [OK]
Common Mistakes:
MISTAKES
  • Omitting ETag disables change detection
  • Using no-store disables caching entirely
  • Assuming max-age alone reduces bandwidth

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes