What happens if your server does XHR by itself?

I've been digging into server side rendering with Angular this week. The architecture seems to be completely isomorphic, so if you get the data on the server or client, this is the same line of code that gets executed. So it would make a type call this.http.get('http://www.example.com/myurl');

where this.http

it would be an instance Http

of @angular/http

.

On the client side, this is very clear. This means the browser is making an XHR request to my server.

Server side ... what's really going on behind the scenes? My guess is that a node server, completely unaware of its domain, will make a regular HTTP request, with DNS lookups and everything else, just to find itself?

Is this accurate?

+3


source to share


1 answer


All comments point to the answer to the question that your server will make a DNS call to go back and hit itself.

Since I was interested to learn about the effectiveness, I did a test: time curl -v http://[mydomain].us-east-1.elb.amazonaws.com/testedself

.



The end point is simply the expressed end point with res.send('Hello World');

. Additional ~ 10MS time in this particular test.

0


source







All Articles