How to force a web browser NOT to cache images
Solution 1:
Armin Ronacher has the correct idea. The problem is random strings can collide. I would use:
<img src="picture.jpg?1222259157.415" alt="">
Where "1222259157.415" is the current time on the server.
Generate time by Javascript with performance.now()
or by Python with time.time()
Solution 2:
Simple fix: Attach a random query string to the image:
<img src="foo.cgi?random=323527528432525.24234" alt="">
What the HTTP RFC says:
Cache-Control: no-cache
But that doesn't work that well :)
Solution 3:
I use PHP's file modified time function, for example:
echo <img src='Images/image.png?" . filemtime('Images/image.png') . "' />";
If you change the image then the new image is used rather than the cached one, due to having a different modified timestamp.