Guys I am new to node js and this behavior is strange to me! In the code snippet below,
\'use strict\';
var http = require(\'http\');
var numberOfRequests = 0;
Usually, when you see two requests for each page request, one is for the desired page and one is for the favicon for the website. This is what most browsers do unless there is meta tag in the page that tells the browser not to request a favicon resource. If you do this in your handler:
console.log(request.url)
That will likely show you what's going on. In general, you don't want to have a web server where you never look at what resource is being requested. If you based your logic on a specific resource being requested such as /
, then you would easily be able to ignore other types of requests such as the favicon.