Consider a REST API response with the following headers:
Cache-Control: max-age=3600, must-revalidate ETag: "abc123"
If a client sends a request with header If-None-Match: "abc123", what will the server most likely respond with?
ETag helps the server decide if the resource has changed.
If the If-None-Match header matches the current ETag, the server returns 304 Not Modified without the body to save bandwidth.
Which Cache-Control directive ensures that the client must check with the server before using a cached response?
Think about which directive means 'always check before use'.
no-cache means the client must revalidate with the server before using the cached response, even if it is fresh.
Given this response header:
Cache-Control: private, max-age=0, must-revalidate
What does this mean for caching behavior?
Consider what private and max-age=0 imply together.
private means only the browser caches it, max-age=0 means it is immediately stale, and must-revalidate forces revalidation before reuse.
Consider this server code snippet that sets ETag header incorrectly:
response.headers['ETag'] = 12345
What error or behavior will this cause?
HTTP headers must be strings.
Setting a non-string value for a header usually raises a TypeError in most server frameworks.
Which statement best explains how ETag headers improve REST API efficiency?
Think about how clients can save bandwidth using ETag.
ETag lets clients send If-None-Match headers so servers can respond with 304 Not Modified if the resource is unchanged, saving bandwidth.