What response should If-Modified-Since HTTP Header

2019-05-05 06:14发布

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?

1条回答
在下西门庆
2楼-- · 2019-05-05 06:57

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.

查看更多
登录 后发表回答