httpheaderif-modified-since

What response should If-Modified-Since HTTP Header return if request is HEAD?


If you send a GET request with an If-Modified-Since header, the server suports it and the file hasn't changed, the server will return a 304 response.

If you sent a HEAD request in the same circumstances, should the server send a 304 response or send back the full headers you would have sent had the file changed?

In short: is GET / HEAD equivalent when requesting a file that has not changed?


Solution

  • As per RFC

    The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request.

    Based on the above, the HEAD request in the same circumstances should return 304.

    In short: is GET / HEAD equivalent when requesting a file that has not changed?

    Again, based on what the RFC has to say, both GET and HEAD should be equivalent.