Bird
0
0

In a REST API, how should the server handle the If-Modified-Since header to effectively minimize data transfer?

hard📝 Application Q8 of 15
Rest API - Caching Strategies
In a REST API, how should the server handle the If-Modified-Since header to effectively minimize data transfer?
AIgnore the <code>If-Modified-Since</code> header and respond with <code>404 Not Found</code>
BAlways respond with <code>200 OK</code> and full resource data regardless of the header
CRespond with <code>304 Not Modified</code> if the resource has not changed since the date in <code>If-Modified-Since</code>
DSend the resource only if the <code>If-Modified-Since</code> date is in the future
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of If-Modified-Since

    This header allows the client to ask the server if the resource has changed since a specific date.
  2. Step 2: Server response behavior

    If the resource has not been modified since the date provided, the server should respond with 304 Not Modified to avoid sending the full resource again.
  3. Final Answer:

    Respond with 304 Not Modified if resource unchanged -> Option C
  4. Quick Check:

    Does the server avoid sending full data when unchanged? [OK]
Quick Trick: Use 304 status to save bandwidth when resource unchanged [OK]
Common Mistakes:
MISTAKES
  • Always sending full data ignoring If-Modified-Since
  • Responding with 404 instead of 304
  • Misinterpreting future dates in the header

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes