Say one do multiple requests to example.com/some/api by XHR.
If one do:
let xhr = new XMLHttpRequest();
xhr.open('GET', 'https:/example.com/some/api?' + query);
xhr.send();
each time, does that make a new connection each time, handshake and all?
And if one reuse the xhr it re-uses the connection if kept alive?
Does it create a new connection each time, or re-use independent on the object, or anything in between?
From what I understand HTTP/2 does not have keep-alive but more in a way of keep connection open as a default. For HTTP/1.1 it depends on headers?
Main thought is that it is better to re-use the xhr if there is a new connection for each object. And on the contrary, if it is handled deeper in the system it's nothing much to twiddle with.
And as a second point is it enough to check for readyState if re-using? If it is 4, is it OK to re-use?