문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top