When creating a web application with an upload image system, there is this problem with cache, you upload and replace an existing image without changing name, the browser still show the old image, you must hit F5 or refresh to force reload the image.
I've been looking for a simple way to fix this common problem.
I found the
Code: Select all
<?php echo '<img src="image.jpg?'.rnd(0,9999).'">'; ?>
there is another trick with the php function DATE, but not good for me
I found an effective solution (i think) using the filesize function, to get the image size in bytes :
Code: Select all
<?php
$the_photo='image.jpg';
$bytes_photo='?'.filesize($the_photo);
echo '<img src='.$the_photo.$bytes_photo.'>';
?>
this fix work fine for me
if you have a better solution.. please share it
thanks