Bird
0
0

Given this server logic:

medium📝 Predict Output Q13 of 15
Rest API - Caching Strategies
Given this server logic:
if request.headers.get('If-None-Match') == current_etag:
    return 304
else:
    return 200 with data and ETag

What will the server respond if the client sends If-None-Match: "xyz789" but current_etag is "abc123"?
A200 OK with data and ETag
B304 Not Modified
C400 Bad Request
D500 Internal Server Error
Step-by-Step Solution
Solution:
  1. Step 1: Compare client's ETag with server's current ETag

    The client sends "xyz789" but the server's current ETag is "abc123", so they do not match.
  2. Step 2: Determine server response based on mismatch

    Since ETags differ, the server sends full data with status 200 and the current ETag.
  3. Final Answer:

    200 OK with data and ETag -> Option A
  4. Quick Check:

    ETags differ -> send data [OK]
Quick Trick: If ETags differ, server sends full data (200) [OK]
Common Mistakes:
MISTAKES
  • Assuming 304 when ETags differ
  • Confusing 400 or 500 errors with ETag mismatch
  • Ignoring quotes in ETag comparison

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes