When loading a single page in Chrome, Chrome sometimes creates one or two additional TCP connections.
Presumably these connections are provisional, in case the page has other assets to request from the server. When there are no other assets to requests, these TCP connections just sit there, instead of being closed. Chrome never sends a request on these connections.
Why, when Chrome knows that there are no more assets to request, does Chrome not close them, but rather relies on the server to time out?
The reason I'm asking is because especially on embedded webserver, this behavior wastes valuable resources.
Also, I would like to understand how the http server is expected to behave. It sounds like the server should send a "Request timeout" 408, but after how long?
Some additional notes:
When I say that Chrome does not close the extra TCP connections, I've set the timeout on the server to 10 seconds. Maybe Chrome eventually will close it if waiting longer, but the initial page loads in < 7ms, so there was plenty of time for Chrome to figure out that there are no additional requests.
I have not found a definitive source that says that these connections are provisional, just educated guesses/speculation like here: Why does Chrome open a connection but not send anything
However, I can see that when a page is loaded which does have additional resource to request, those "provisional" TCP connections are used.
Why, when Chrome knows that there are no more assets to request ...
Chrome does not know that these connection will not be used. There might be some script on your page which will make requests to the server eventually. Or the user might follow links which request new resources from your server. Thus it makes sense to keep these connection open in order to improve the performance in common use cases.
Also, I would like to understand how the http server is expected to behave. It sounds like the server should send a "Request timeout" 408, but after how long?
From the server side you can simply close the connections. Since no request is done no response is expected, including no 408 response. That's the general behavior with idle connections, i.e. connections without outstanding response - both client and server can simply close these at any time.