U
U
user-vova2017-08-06 17:05:52
Apache HTTP Server
user-vova, 2017-08-06 17:05:52

Browser ignores keep-alive?

Hey! Apache has keep-alive enabled with a timeout of 30 seconds. Firebug says that the browser makes a request with a keep-alive header, and the server adds it in the response. But the list of open connections says otherwise. There are 5 imgs in the index.html test page. When switching to it, 6 connections are opened that live for 30 seconds. Those. the browser opens a keep-alive connection for every request. And there should be one connection for all requests. What could be the problem? Tested in chrome, opera and firefox.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
U
user-vova, 2017-08-06
@user-vova

Stalker_RED,
Fixid,

Wiki: "keep-alive - use a single TCP connection to send and receive multiple HTTP requests and responses instead of opening a new connection for each request-response pair" In practice, a new connection is created for each request-response pair. As I understand the wiki, is keep-alive just designed to load content within a single connection? If I'm a fool, then in what cases is keep-alive useful? Solution in the comments

M
Mercury13, 2017-08-07
@Mercury13

This is another thing that is indirectly related to keep-alive. This is loading information into multiple streams.
Why six connections and not five is another question. Here's what I would guess. The browser parsed index.html and saw a picture there. We create a new HTTP connection (unencrypted) - two pings later, the data went. Let's use the existing one - one ping later. With a little ping, the browser just thought it would be faster like this. Or maybe the browser is just dumb and if we fit into the number of connections to one server, we create new ones, and that’s all.
But the fact that all the pictures are in different streams is true. If we consider the network speed to be "infinite", for each of them the information will go with a delay of two pings. If we worked in one stream, the first one would arrive with a delay of 2 pings, the second one would arrive with a delay of 3 pings, the third one would arrive with 4 pings ... But the SPDY and HTTP / 2 protocols allow you to say: “Give me pictures A, B and C,” and they all, ONE CONNECTION, will come with a delay of two pings.
In other words:
HTTP (all timestamps - when they were sent from/received by the client):
To: SYN: (+0 pings)
S: SYN+ACK (+1 ping)
To: ACK (+1 ping)
To: Request 1 (+1 ping)
From: Reply 1 (+2 pings)
To: Request 2 (+2 pings)
From: Reply 2 (+3 pings)
HTTP2:
To: SYN: (+0 pings)
C: SYN+ACK (+1 ping)
C: ACK (+1 ping)
C: Requests 1, 2 (+1 ping)
C: Replies 1, 2 (+2 pings) Plays
a role on real "not very fast" connections not only pings, but also transfer speed. Then the pictures will begin to appear not one at a time, but eight (or how many connections there are) - this can also affect the impression of the browser. In addition, if there was a congestion on the local network gateway, then if one connection goes haywire, others will bring something. And if the network is not very well configured, this will also increase the transfer speed by an eightfold (actually, in the early 2000s, I downloaded a 10-megabyte driver at the university for a change of 100 streams).
I would advise you to make about twenty pictures - and then the reuse of existing connections will begin.

S
Stalker_RED, 2017-08-06
@Stalker_RED

And there should be one connection for all requests.
why all of a sudden?
https://ru.wikipedia.org/wiki/%D0%9F%D0%BE%D1%81%D...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question