Web Technology Basics

A browser requests an image it received earlier once again, putting the ETag value from that earlier response into the If-None-Match header. If the image on the server has not changed, which of the following is the correct server response?

  1. A200 OK, sending the whole image body again even though it is the same as before
  2. B304 Not Modified with no body, and the browser uses the image it has stored
  3. C404 Not Found, making the browser delete its stored old image and fetch it again
Show answer and explanation

Answer: B. 304 Not Modified with no body, and the browser uses the image it has stored

An ETag is an identifier that represents a particular version of a resource. The browser puts the ETag into If-None-Match to send a conditional request meaning "send it if it has changed since this version", and if it has not changed, the server returns 304 Not Modified without a body. This takes only the one round trip for the check, and the image data does not have to be sent again. If it has changed, the server returns 200 OK with the new body and a new ETag. Within the period set by max-age in Cache-Control, the browser uses its stored copy without even this check.

  • A. The image has not changed, so the body need not be sent again. Avoiding that is the purpose of a conditional request.
  • B. Correct. 304 means "it has not changed, so the stored copy may be used".
  • C. 404 is the code for a resource that was not found, but the image exists.
Practice this topic Back to topic

Books on Web Technology Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Web Technology Basics questions

  1. Which of the following correctly describes HTTP/2 and HTTP/3?
  2. From a web server with an RTT of 40 ms, one HTML file and the four images it references are fetched one after another. Assume that establishing a TCP connection takes one round trip and each request and response take one round trip, and ignore data transfer time, server processing time, TLS and connection teardown. Which of the following is the difference in total time between opening a new TCP connection for each object and reusing one TCP connection (a persistent connection)?
  3. HTTP is a stateless protocol. Which of the following correctly describes what this means together with the usual way a website keeps a user logged in?
  4. Which of the following correctly describes the cookie set by the header above?
  5. Which of the following correctly describes a difference between the browser's localStorage and cookies?