Solution 1 - Serving images via PHP:
This is a solution to serve images in a way that does not remain 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' );
?>
Changing the minhaimagem.jpg
for:
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 server files.
Solution 2 - Changing SRC via PHP:
If images only need to be updated on your page, you can do the src
thus:
echo '<img src="/link/para/imagem.jpg?'.date("YmdHis").'">';
In this way, every second query string of the links will change, forcing a reread, however, always pointing to the same file paths on the server.
Orphan question. User view 21/10/2014. In this case the question stays like this until eternity @Bacco?
– durtto
@durtto is part of it. Not everything will have Accept, but whoever researches to solve the same problem, will find the answers :)
– Bacco