Forum Moderators: open
The method has been called "Comet" by Alex Russell [alex.dojotoolkit.org]
It has also been called the slow load technique.
It is not terribly new but it is getting new life. If you remember the days before the browser supported animated GIFs there was a trick back then of sending a gif from a perl script and when it finished you ran the sleep command and sent the same gif again. This kept a connection pinned up between the browser and the server and drove system administrators batty.
In order to continue to stay on their good side we never used this on a large scale application and we did not tell people how to do it. (if connections do not close then the server will run out of available connections with less traffic.)
However Apache 2.2 is supposed to support these pinned up connections and if you don't mind the dirty looks from the sysadmin this is how it is done.
Write a cgi that runs slow. To do this you will send some javascript variables and then sleep and send more javascript variables and sleep. When you want to trigger something in the browser send a call to a function in the parent window. then go back to the loop.
On the browser, have a zero sized frame open the slow cgi and just let it run.
To see some sample code, Bryce Nesbitt wrote a simple description. [obviously.com]
Remember, until webservers optimize this kind of behavior it is not advisable with high traffic sites (we don't all have google's resources). Check with your sysadmin or maybe just make him wonder why the webserver is suddenly requiring many more connections that are not dropping.
Use it in good health.
Al Anderson