If-Modified-Since HTTP Header在请求是HEAD时返回什么样的响应? [英] What response should If-Modified-Since HTTP Header return if request is HEAD?

查看:109
本文介绍了If-Modified-Since HTTP Header在请求是HEAD时返回什么样的响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您发送带有If-Modified-Since标头的GET请求,服务器支持它并且文件没有更改,则服务器将返回304响应。



如果您在相同的情况下发送了HEAD请求,服务器是否应发送304响应或发回您将发送的文件已更改的完整标题?

简而言之:在请求一个没有改变的文件时,GET / HEAD是否等价? RFC


HEAD方法与GET
相同,除了服务器不能在响应中返回
a message-body。包含在HTTP
头文件中的
metainformation响应HEAD请求
应该与为响应GET请求而发送的信息
相同。


基于上述情况,相同情况下的HEAD请求应该返回304.


总之:请求一个没有更改
的文件时,GET / HEAD是否等于



<再次,根据RFC的说法,GET和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?

解决方案

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.

这篇关于If-Modified-Since HTTP Header在请求是HEAD时返回什么样的响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆