Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
192 views
in Technique[技术] by (71.8m points)

html - HTTP 1.1 GET requests are too quick for server to respond causing TCP Retransmission

I am making a webserver with RTOS on a MCU. The network library uses HTTP 1.0 and closes the TCP socket and re-listens after each request.

The web page I am serving has multiple .js files that it needs to load after the html has fully loaded.

Once the html content is sent, immediately afterwards the web browser sends a "GET /file.js HTTP/1.1" message. This message is then retransmitted 3 or 4 times with TCP Retransmission before the web server is finally able to handle it.

Question 1: Is this fast transmission due to the web browser still attempting HTTP 1.1 protocol of not closing the connection? The content status reply message from our server is HTTP 1.0, but the web browser keeps requesting GET with HTTP 1.1.

Question 2: Is there a way to tell the web browser to slow down so it doesn't congest the network with TCP Retransmissions?

Any suggestions are helpful.

question from:https://stackoverflow.com/questions/66055413/http-1-1-get-requests-are-too-quick-for-server-to-respond-causing-tcp-retransmis

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is perfectly find to do a HTTP/1.1 request but get a HTTP/1.0 response back. There is no way for the server to say the client to slow down: since each new request is done over a new TCP connection there is no TCP flow control which might be used for this.

The problem is that your server obviously is not able to handle multiple requests at the same time. This means that the content served should be designed in a way that such requests are not needed in the first place: instead of embedding multiple resources in the same page the site should be constructed to retrieve only a few resources. This can for example be done by merging multiple Javascript files into a single one and by making excessive use of client side caching (i.e. set the right Cache-Control headers).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...