Background: I am trying to get ApacheBench working on my custom server. I tried issuing ab -n 1 -c 1 http://localhost:1337/index.html
and I sniffing the connection (with wireshark) I see wayyy more than one request is sent.
Example Request:
GET /index.html HTTP/1.0 Host: localhost:1337 User-Agent: ApacheBench/2.3 Accept: */* (repeats more times than I care to count)
I assumed as RFC 1945 says "Except for experimental applications, current practice requires that the connection be established by the client prior to each request and closed by the server after sending the response." This works with ApacheBench when I request one page. However, if I up the number of requests to 10, I get "Connection reset by peer." This makes sense considering that I closed the connection.
I tried the same procedure with Google, however, and it works fine there for both cases. So, how am I supposed to know when to close the connection for HTTP 1.0?
after the current request/response is complete. HTTP/1.1 applications that do not support persistent connections MUST include the "close" connection option in every message.
Persistent connections time out after 115 seconds (1.92 minutes) of inactivity which is changeable via the configuration.
In HTTP 1.1 version, by default uses a persistent connection where it doesn't close automatically after a transaction. But the HTTP 1.0 will not consider the connections as persistent, so if you want to keep it alive, you need to include a keep-alive connection header.
By default, HTTP connections close after each request. When someone visits your site, their browser needs to create new connections to request each of the files that make up your web pages (e.g. images, Javascript, and CSS stylesheets), a process that can lead to high page load times.
In HTTP 0.9, the server always closes the connection after sending the response. The client must close its end of the connection after receiving the response.
In HTTP 1.0, the server always closes the connection after sending the response UNLESS the client sent a Connection: keep-alive
request header and the server sent a Connection: keep-alive
response header. If no such response header exists, the client must close its end of the connection after receiving the response.
In HTTP 1.1, the server does not close the connection after sending the response UNLESS the client sent a Connection: close
request header, or the server sent a Connection: close
response header. If such a response header exists, the client must close its end of the connection after receiving the response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With