I understand what a HEAD request is, and what it could be used for. Will any standard, modern browser ever send a HEAD request? If so, in what context?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
A browser will send a HEAD
request if that is explicitly requested in an XMLHttpRequest
, but I'm fairly certain that the browser will never send a HEAD
request of its own accord. My evidence is that the Tornado web server defaults to returning an error for HEAD
requests and I've never heard of anyone running into problems related to this (or even being aware of it).
HEAD
is mostly obsolete IMHO: on a dynamic web site it is unlikely to be significantly more efficient than a GET
, and it can usually be replaced by one of the following:
- Conditional
GET
withIf-Modified-Since
orIf-None-Match
(used for caching) - Partial
GET
withRange
header (used for e.g. streaming video) OPTIONS
(used for CORS preflight requests)