Node HTTP requests are not executed concurrently if made from the same browser

var http = require('http');
http.createServer(function (req, res) {
    setTimeout(function () {
        res.write("hello");
        res.end();
    }, 10000);
}).listen(8080);

      

this is my simple node server running on localhost.

Now if I remove this localhost: 8080 url from two different browsers at the same time, I get a response at the same time in both browsers, i.e. after about 10 seconds.
But, if I do it from two different tabs of the Chrome browser, it takes 10 seconds for one tab and another 10 seconds for the second tab.

It looks like the requests are being processed one after the other, rather than simultaneously.
can someone explain?

+3


source to share


1 answer


This is a browser issue only when you are making two requests in the same browser (or in the browser profile) and separate tabs (XHR requests can run concurrently).

Sources:



Chrome stops making multiple requests for the same resource? Multiple PHP script instances will not be loaded at the same time in the same browser from the same url

+1


source







All Articles