Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Session, HTTP Connection?

I have been reading this and this. After reading I found myself very confused with my basics now. Please help me out as it involves the basics of networking and JSPs & Servlets

Consider this hypothetical situation:

If I open some www.xyz.com on some browser and don't do anything on that page for day.

Q.1 Would that mean that same connection still exists if next day I request something from that page. Considering Connection: keep-alive is there.

Q.2 How does session works in this context -I have found that if session gets expired so will connection, so what is the difference between HTTP Connection and Session ? Like what happens when we open multiple tab of Facebook in same browser (It is same session but different connection ? Am I correct ?)

Q.3 As mentioned in this article

A major improvement in the HTTP 1.1 standard is persistent connections. In HTTP 1.0, a connection between a Web client and server is closed after a single request/response cycle. In HTTP 1.1, a connection is kept alive and reused for multiple requests. Persistent connections reduce communication lag perceptibly, because the client doesn't need to renegotiate the TCP connection after each request.

How does browser maintain a persistent connection ?

NOTE : It would be better if someone could answer this question this way

like image 808
balboa_21 Avatar asked Nov 04 '15 10:11

balboa_21


1 Answers

To answer your questions:

A1: No, next day connection won't be there. Keep-Alive (in HTTP) values are usually low enough to not make it through the day.

A2: Session is maintained server side. It has nothing to do with communication's Keep-Alive. It has a separate value for its expiry time (depends on how you configure it). You are correct: different tabs, same session, different connections. Usually sessions are glued together using common cookies. That's why when you clean your cookies, you usually loose all your sessions.

A3: Browser simply does not close the TCP/IP connection. That's how it does it.

like image 145
Pablo Santa Cruz Avatar answered Oct 13 '22 23:10

Pablo Santa Cruz