I've tried to make a simple API. If someone/something queries:
myIP:port/query
It should serve some result. However, I've noticed that (at least) when the query is made by a browser (Chrome), the server receives two requests. If the server simply is set up as follows:
http.createServer(function (request,result) {
console.log(request.url);
handleRequest(request,result);
}).listen(3000, '0.0.0.0');
It prints two request urls:
I imagine that this means that the requesting client automatically draws an additional request hoping to load the favicon as well as the actual page.
Is this assumption correct?
Is there anything I can do when making the request to prevent this? Is it driven by chrome or would it also occur if I queried the page using ajax?
What is the best practice on the server side for filtering out the favicon request with minimal wasted effort by the server?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…