http HEAD vs GET performance -


i setting-up rest web service need answer yes or no, fast possible.

designing head service seems best way know if gain time versus doing request.

i suppose gain body stream not open/closed on server (about 1 millisecond?). since amount of bytes return low, gain time in transport, in ip packet number?

thanks in advance response!

edit:

to explain further context:

  • i have set of rest services executing processes, if in active state.
  • i have rest service indicating state of these first services.

since last service called large set of clients (one call expected every 5ms), wondering if using head method can valuable optimization? 250 chars returned in response body. head method @ least gain transport of these 250 chars, impact?

i tried benchmark difference between 2 methods (head vs get), running 1000 times calls, see no gain @ (< 1ms)...

a restful uri should represent "resource" @ server. resources stored record in database or file on filesystem. unless resource large or slow retrieve @ server, might not see measurable gain using head instead of get. retrieving meta data not faster retrieving entire resource.

you implement both options , benchmark them see faster, rather micro-optimize, focus on designing ideal rest interface. clean rest api more valuable in long run kludgey api may or may not faster. i'm not discouraging use of head, suggesting use if it's "right" design.

if information need meta data resource can represented nicely in http headers, or check if resource exists or not, head might work nicely.

for example, suppose want check if resource 123 exists. 200 means "yes" , 404 means "no":

head /resources/123 http/1.1 [...]  http/1.1 404 not found [...] 

however, if "yes" or "no" want rest service part of resource itself, rather meta data, should use get.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -