A developer wants to check if a large file has changed on a remote server before downloading it. Which HTTP request pattern achieves this most efficiently?
- A.Send a conditional GET with 'If-None-Match' (ETag) or 'If-Modified-Since' header; the server returns 304 Not Modified with no body if unchanged, saving bandwidth
- B.Send a HEAD request and compare Content-Length
- C.Send a Range request for the first 100 bytes and compare them
- D.Check the Last-Modified header in a GET response and compute a hash
Why A is correct
Conditional GET requests use If-None-Match (matches against ETag) or If-Modified-Since (matches against Last-Modified date). If the resource is unchanged, the server responds 304 Not Modified with no body, saving bandwidth. This is the standard HTTP caching validation mechanism. HEAD requests are also efficient for metadata checks but they do not leverage server-side cache validation logic automatically.
Know someone studying for Web App Fundamentals? Send them this one.