Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: NPH and Connection: Keep-Alive

by eric256 (Parson)
on Mar 24, 2009 at 21:59 UTC ( #752970=note: print w/ replies, xml ) Need Help??


in reply to NPH and Connection: Keep-Alive

After your script ends, how would you send more information to the browser?

Here is my simplified understanding of your question: Browser requests page from Server. Server runs script, script returns partial output, Server sends output to browser, script ends...Server sends what to the browser?</>

Here is my simplified understanding of what I think you want: Browser requests page from Server. Server runs script, script returns partial output, Server sends output to browser, script loops and sends more info to the server, server continues sending output to the browser until the script ends.</>


___________
Eric Hodges


Comment on Re: NPH and Connection: Keep-Alive
Re^2: NPH and Connection: Keep-Alive
by gfairweather (Novice) on Mar 24, 2009 at 23:28 UTC

    After the script ends the client will have the HTML page and the browser will then request the css, the javascript and the images that are linked in the document.

    Trying to put it simply, the script runs from top to bottom with 2 exit points. If cache control is met by comparing last modifed date and etag then the script exits with a 304. Otherwise the HTML is built from a template and held in a scalar, so the length can be calculated, the headers are output followed by the body and then the script exits.

    My expectation, based on how Apache serves files, is that if the browser sends Keep-Alive then the server responds with Keep-Alive, a timeout value and max objects value. If the next request is within the timeout value and the max objects has not been met then the request is served on the open connection, the timer is reset and the max object decremented by 1. If there is no further request within the timeout or the max objects is met then the connection is closed by the server. You can partially see this in the two header traces that I posted above.

    What I see from using telnet/browser and wireshark is that as soon as the script exits, instead of the connection being kept alive, the server sends FIN,ACK, the broswer acknowledgesACK and then sends FIN,ACK and the server acknowledgesACK and the connection is closed immediately. Any further requests for the css, javascript and images open a new connection and keep-alives function as expected.

    What I'm trying to figure out is how do I replicate the normal Apache behavior for keep-alive. I mimic the headers exactly but Apache does not honour what has been sent. My assumption is that it's to do with the fact that it's NPH. Normally Apache would append these headers. What I need to be able to do is access the Apache timeout value and the max objects value so I can set those appropriately and inform Apache to decrement the max objects value and have Apache not tear down the connection.

    That's my understanding and I hope that makes sense.

Re^2: NPH and Connection: Keep-Alive
by gfairweather (Novice) on Apr 01, 2009 at 02:29 UTC

    Thanks for your interest but the issue has been resolved and I no longer need to work the problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://752970]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (13)
As of 2014-07-22 21:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (128 votes), past polls