By default Connection
Header is set to Keep-Alive
in browers, to make it possible to keep connection open for further requests from browser.
When I make Connection
header to close
, what may be the difference ?
Will that affect any performance issue ?
(one addition: I am setting header from xmlhttprequest)
The Connection general header controls whether the network connection stays open after the current transaction finishes. If the value sent is keep-alive , the connection is persistent and not closed, allowing for subsequent requests to the same server to be done.
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.
To add custom headers to an HTTP request object, use the AddHeader() method. You can use this method multiple times to add multiple headers.
When you make requests with "Connection: keep-alive" the subsequent request to the server will use the same TCP connection. This is called HTTP persistent connection. This helps in reducing CPU load on the server side and improves latency/response time.
If a request is made with "Connection: close" this indicates that once the request has been made the server needs to close the connection. And so for each request a new TCP connection will be established.
By default HTTP 1.1 client/server uses keep-alive whereas HTTP 1.0 client/server doesn't support keep-alive by default.
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