Bird
0
0

You want to optimize your REST API to reduce bandwidth by using If-None-Match. Which of the following sequences correctly describes the client-server interaction to achieve this?

hard📝 Application Q15 of 15
Rest API - Caching Strategies
You want to optimize your REST API to reduce bandwidth by using If-None-Match. Which of the following sequences correctly describes the client-server interaction to achieve this?
AClient sends request with <code>If-None-Match</code> -> Server always returns 200 with data and ETag -> Client caches data
BClient sends request without ETag -> Server sends data with ETag -> Client caches data and ETag -> Client sends request with <code>If-None-Match</code> header -> Server returns 304 if data unchanged
CClient sends request with ETag in body -> Server returns 304 if data unchanged -> Client discards cached data
DClient sends request without headers -> Server returns 304 if data unchanged -> Client updates cache
Step-by-Step Solution
Solution:
  1. Step 1: Understand the correct use of If-None-Match and 304

    The client first gets data and ETag, caches them, then sends If-None-Match with ETag to check for changes.
  2. Step 2: Identify the correct sequence

    The sequence that starts with an initial request without the ETag header, receives data and ETag from the server, caches both, and then uses If-None-Match on future requests, receiving 304 if unchanged, is correct.
  3. Final Answer:

    Client sends request without ETag -> Server sends data with ETag -> Client caches data and ETag -> Client sends request with If-None-Match header -> Server returns 304 if data unchanged -> Option B
  4. Quick Check:

    Proper If-None-Match flow [OK]
Quick Trick: Initial fetch no ETag, then use If-None-Match with ETag [OK]
Common Mistakes:
MISTAKES
  • Sending ETag in request body instead of header
  • Expecting 304 without sending If-None-Match
  • Ignoring caching after 304 response

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes