I am trying to make a JavaScript animation of real-time images - i.e.
images that will periodically change on the server. The problem I am
having is that the JavaScript animation I have created is always using
the images from the cache, even though I have set the HTTP response
header on the server (via .htaccess) so that the browser should
validate the image in the cache against the image on the server for
freshness. I have tested the HTTP response headers I am using and
they are working in other instances on the same server, so I am not
sure what I am doing wrong.
As to how my animation works, basically, I load a page with an image
on it and the image has an onLoad event handler that runs a JavaScript
function. The JavaScript function then figures out which image needs
to be displayed next, then does a preload on it (i.e. img=new Image;
img.src=imgSrc;) and then does a
window.setTimeout to change the src of the image
(i.e. document.images["img"].src=page;) in X seconds. I suspect that
what is happening is that the whole business of preloading the image
using JavaScript and changing the src of the image using JavaScript
doesn't involve making an actual request to the server, since I am not
reloading the page, and therefore the HTTP response headers I set on
the server aren't being applied.
My question is this: does anyone know of a general method for making a
JavaScript animation that will display the new versions of images
(same file names) when they have changed on the server?