Here’s a nifty little trick that might get you out of a bind:
Say you have a web app in which the user can change the images by uploading new image files. Say then that the application requires that the image filename remain the same. See the problem?
The image may have changed but your browser is still looking at the same filename, so it will display its cached image. Of course, you could try an edit your HTML to that caching doesn’t occur, but we like caching, so here’s a better solution.
An image file, like a script file, can accept an argument when requested with HTTP. For instance, the image below is requested so:
my_image.src=”images/pottery.jpg?” + (new Date()).getTime();
image_td.innerHTML = “<IMG src=images/pottery.jpg?” + (new Date()).getTime() + “</IMG>”;