Solution 1 - Serving images via PHP:
This is a solution to serve images so that they do not stay in the browser cache, setting the appropriate headers via PHP:
<?php
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Pragma: no-cache' );
header('Content-type: image/jpeg');
readfile( 'minhaimagem.jpg' );
?>
Replacing minhaimagem.jpg
with:
readfile( '/caminho/para/imagem'.$_GET['img'] );
You can use URLs in this format, for example:
http://example.com/nocache.php/foto12.jpg
This is a simplification to illustrate the basic steps. Make sure to do an extra check in PHP to not give access to other files on the server.
Solution 2 - Changing SRC via PHP:
If the images only need to be updated on your page, you can do src
like this:
echo '<img src="/link/para/imagem.jpg?'.date("YmdHis").'">';
In this way, every second the query string will change, forcing a rereading, however, always pointing to the same file paths on the server.