What exactly does a "persistent connection" mean?
Asked Answered
S

3

23

I read about "HTTP persistent connection" but somehow I don't seem to understand what does persistent mean in this context.
Could you'll elaborate?

Sanitarium answered 26/9, 2009 at 3:11 Comment(1)
What Chaos means is that the connection between the client and server is not closed after the information exchange - leaving it open for further communication. This is much faster than establishing a new connection everytime you need to transmit information.Strep
D
20

All the discussion till now has been from the browser side of things. The browser first request the actual page, and it parses the page and finds out all other resources that it needs before it can render that page. The browser requests these resources and other dependent resources one by one. So maintaining a persistent connection is very efficient here, as the overhead of creating and destroying connections is avoided.

Now from web server side of things, a persistent connection would be one that allows it to "push" content to the web browser. Now HTTP doesn't support this. So, there are few workarounds with javascript where the page is basically refreshed after a while.

You can see this being trick being used by many web based email providers which continuously keep checking in the background for new mails. This gives a feeling that when a new mails arrives, the server "pushes" the new mail notification to the web browser. But in fact, its actually the web browser which keeps on checking the server for any new mail.

Also another point that I would like to state is that we actually don't see any page refresh that's because of another trick which allows only specific parts of the page to be refreshed by the request. (HINT: AJAX)

Dewittdewlap answered 26/9, 2009 at 3:47 Comment(4)
If I keep a conncection open with a webserver will the browser show continuosly a loading bar?Sanitarium
A web browser will only show a loading bar, if it actually requests something. Background stuff whether a connection is open or not shouldn't get reflected in the UI of the browser.Dewittdewlap
How does websocket work in comparison to persistent http connection? You said it is actually the browser pulling data from server while making it look like the server is "pushing" data to the client. Do websockets actually achieve "pushing" from server to the client?Stowers
@Sunny As of my understanding websockets work over TCP rather than HTTP thus making it possible to establish and keep "real" persistent connections.Prate
O
32

It means the server doesn't close the socket once it's finished pushing out the response (so the length of the response has to be otherwise indicated, via headers or chunking), so the client can make other requests on the same socket. A web page often requests several other pieces (images, CSS, scripts, ...) on the same server as the page itself, so reusing the socket for some of those further requests to the same server can reduce overall latency compared to closing the original socket and opening new ones for all the follow-on requests.

Operon answered 26/9, 2009 at 3:15 Comment(2)
As darkassassin93 has stated that the connection will die out in case of out.close() on a Servlet. In this case how could we implement HTTP persistent connection on a Java Tomcat server? Or will we have to use 3rd party tools to implement this? Another question is what about the client side?Sanitarium
@Kevin, you have no control over the browser ("client side"): it will establish its own policies (you can just hope it supports "stay alive"; most do). Re calling .close, I do believe that closes the connection (that being its specific purpose) so the way to (hopefully, browser cooperating) NOT close the connection is NOT to call close -- may not be sufficient but is surely necessary.Operon
D
20

All the discussion till now has been from the browser side of things. The browser first request the actual page, and it parses the page and finds out all other resources that it needs before it can render that page. The browser requests these resources and other dependent resources one by one. So maintaining a persistent connection is very efficient here, as the overhead of creating and destroying connections is avoided.

Now from web server side of things, a persistent connection would be one that allows it to "push" content to the web browser. Now HTTP doesn't support this. So, there are few workarounds with javascript where the page is basically refreshed after a while.

You can see this being trick being used by many web based email providers which continuously keep checking in the background for new mails. This gives a feeling that when a new mails arrives, the server "pushes" the new mail notification to the web browser. But in fact, its actually the web browser which keeps on checking the server for any new mail.

Also another point that I would like to state is that we actually don't see any page refresh that's because of another trick which allows only specific parts of the page to be refreshed by the request. (HINT: AJAX)

Dewittdewlap answered 26/9, 2009 at 3:47 Comment(4)
If I keep a conncection open with a webserver will the browser show continuosly a loading bar?Sanitarium
A web browser will only show a loading bar, if it actually requests something. Background stuff whether a connection is open or not shouldn't get reflected in the UI of the browser.Dewittdewlap
How does websocket work in comparison to persistent http connection? You said it is actually the browser pulling data from server while making it look like the server is "pushing" data to the client. Do websockets actually achieve "pushing" from server to the client?Stowers
@Sunny As of my understanding websockets work over TCP rather than HTTP thus making it possible to establish and keep "real" persistent connections.Prate
C
-2

I think this is a switching for http or https for website browser. If you have old https:// and you are now using http for browser .htaccess file then this problem should created via yoast plugins one page crawl page. don't worry about it is not important error. For hackers this is a way to hack your website if your ssl connection is empty they should attach there page or domain to your ssl connection e.b http://www.example.com and when you brows https://www.example.com in browser there are some other link with open your site domain.

Solution for this always use your full address for website: to protect hackers against your website use ssl and https:/ page for your website.

Then this problem have never scene in any test site or page.

Chipper answered 28/2, 2016 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.