Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

what significance has Connection :"keep-alive" in response headers

HI,
In a web application i saw the following in response headers :
Connection :"keep-alive"
I want to mimic it and thinking of adding the following to my spring mvc code :
        response.setHeader("Connection", "keep-alive");
Does it make any difference whether i pass that in header or not ?
What does it mean ?

Thanks
Avatar of Francisco Igor
Francisco Igor
Flag of Canada image

Conection: keep-alive means a request with a persistent connection.
The communication socket keeps alive for multiple requests
The common behavior is one connection-request-response. With keep alive, the  browser (client) can request multiple resources using a single connection socket.

When you send this header, the client (only if supports keep-alive)  tries to keep sending request using sonly one connection until the connection is closed,

See more details:
https://en.wikipedia.org/wiki/HTTP_persistent_connection
Avatar of Rohit Bajaj

ASKER

hi
so it makes sense to send back keep alive in response only if the request has keep alive ?
its like if the client has sent keep alive then it means it supports persistent connection and when we send it in response then a kind of approval is send which forces client to keep the connection open ?
is it possible to see it happenning in some open source browser code , just to get more familiar with concept?
ASKER CERTIFIED SOLUTION
Avatar of Francisco Igor
Francisco Igor
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial