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?
GET /favicon.ico
if there is no favicon specified as a <link rel="icon" ... />
in the head of the HTML body./favicon.ico
if the request is made via AJAX, but it is likely that the browser has already made that request by this time (you have to have loaded the page to perform an AJAX request).<link ref="icon" ... />
statement in the head of the document.