Bird
0
0

How can you combine If-None-Match header handling with JSON response compression to improve REST API performance?

hard📝 Application Q9 of 15
Rest API - Caching Strategies
How can you combine If-None-Match header handling with JSON response compression to improve REST API performance?
ASend 304 with compressed JSON body if ETag matches
BCompress JSON always, ignore ETag and send 200
CCheck ETag match first, return 304 without body, else compress JSON and send 200
DDisable compression when <code>If-None-Match</code> header is present
Step-by-Step Solution
Solution:
  1. Step 1: Use ETag to avoid sending unchanged data

    If ETag matches, respond 304 with no body to save bandwidth.
  2. Step 2: Compress JSON only when sending data

    If resource changed, compress JSON response to reduce size and send 200 OK.
  3. Final Answer:

    Check ETag match first, return 304 without body, else compress JSON and send 200 -> Option C
  4. Quick Check:

    Combine ETag check and compression for best performance [OK]
Quick Trick: Return 304 before compressing JSON to save resources [OK]
Common Mistakes:
MISTAKES
  • Sending compressed body with 304 status
  • Ignoring ETag and compressing always
  • Disabling compression unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes