Bird
0
0

You want to optimize your REST API to reduce bandwidth by using ETags. Which approach correctly implements conditional GET requests with ETags?

hard📝 Application Q15 of 15
Rest API - Caching Strategies

You want to optimize your REST API to reduce bandwidth by using ETags. Which approach correctly implements conditional GET requests with ETags?

1. Server generates ETag for resource.
2. Server sends ETag in response header.
3. Client stores ETag.
4. Client sends GET with If-None-Match header.
5. Server compares ETag and returns 304 if unchanged.
6. Otherwise, server sends new data with new ETag.

Which step is missing or incorrect?

AStep 6: Server should always send 200 status even if unchanged
BStep 4: Client should send If-Modified-Since instead of If-None-Match
CStep 3: Client should not store ETag
DStep 5: Server must compare ETag including quotes exactly
Step-by-Step Solution
Solution:
  1. Step 1: Review each step for correctness

    Steps 1-4 are correct standard flow for ETag conditional requests.
  2. Step 2: Identify subtle issue in step 5

    Server must compare ETag values exactly, including quotes, or else conditional check fails.
  3. Step 3: Confirm other options are incorrect

    Client should store ETag (step 3), If-None-Match is correct header (step 4), and 304 status is correct for unchanged (step 6).
  4. Final Answer:

    Step 5: Server must compare ETag including quotes exactly -> Option D
  5. Quick Check:

    Exact ETag match including quotes is required [OK]
Quick Trick: ETag comparison must be exact including quotes [OK]
Common Mistakes:
MISTAKES
  • Ignoring quotes in ETag comparison
  • Using wrong conditional header
  • Sending 200 instead of 304 for unchanged resource

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes