http HEAD vs GET performance

后端 未结 8 778
无人共我
无人共我 2020-11-30 17:57

I am setting-up a REST web service that just need to answer YES or NO, as fast as possible.

Designing a HEAD service seems the best way to do it but I would like to

相关标签:
8条回答
  • 2020-11-30 18:54

    Your performance will hardly change by using a HEAD request instead of a GET request.

    Furthermore when you want it to be REST-ful and you want to GET data you should use a GET request instead of a HEAD request.

    0 讨论(0)
  • 2020-11-30 18:56

    I don't understand your concern of the 'body stream being open/closed'. The response body will be over the same stream as the http response headers and will NOT be creating a second connection (which by the way is more in the range of 3-6ms).

    This seems like a very pre-mature optimization attempt on something that just won't make a significant or even measurable difference. The real difference is the conformity with REST in general, which recommends using GET to get data..

    My answer is NO, use GET if it makes sense, there's no performance gain using HEAD.

    0 讨论(0)
提交回复
热议问题