[mod_python] Refresh browser's images on server's request

Byron Ellacott bje at apnic.net
Sun Nov 21 18:08:55 EST 2004

rednelb wrote:
> Please can someone tell me if it is possible, and if so - how, to 
> refresh images in client's browser only when they change on server? I'm 
> not thinking of a cache, rather imagine following: a few people are 
> looking on the same web page. It has a few images. A user can change an 
> image. When this happens, the others should immediately see the changes, 
> e.g. their browsers have to refresh the page automatically.
> Can Mod_python do this?

HTTP cannot do this.

HTTP is a pull mechanism: the client issues a request, the server 
provides a response.  Server side events cannot cause the client to 
issue a new request, because the client remains blissfully unaware of them.

You can work around it.  You can send an animated GIF, hold the 
connection open and send the new image as a new frame when you receive 
it.  You can send a Java applet, and have that applet maintain a 
connection to the server.  You can have the client refresh the image 
periodically, via JavaScript or a Refresh header.  You can maintain the 
connection for a surrounding HTML page, and continuously send inline 
<script> elements to change an image's source.

But just be aware, they are all hacks, and they will all cause their own 


More information about the Mod_python mailing list