I checked all the answers, and the best one seemed (and itβs not):
<img src="image.png?cache=none">
.
However, if you add the cache = none parameter (which is a static "nothing"), this does not affect anything; the browser is still loading from the cache.
The solution to this problem:
<img src="image.png?nocache=<?php echo time(); ?>">
where you basically add a unix timestamp to make the parameter dynamic and without a cache, it worked.
However, my problem was slightly different: I uploaded the generated php diagram image on the fly and controlled the $ _GET parameters page. I wanted the image to be read from the cache when the GET URL parameter remains unchanged and is not cached when the GET parameters are changed.
To solve this problem, I needed a hash of $ _GET, but since this is an array, this is the solution:
$chart_hash = md5(implode('-', $_GET)); echo "<img src='/images/mychart.png?hash=$chart_hash'>";
Edit
Although the solution above works just fine, sometimes you want to serve a cached version of UNTIL, the file is modified. (with the above solution, it completely disables the cache for this image) Thus, there is a change in the use of the image file to serve the cached image from the UNTIL browser:
echo "<img src='/images/mychart.png?hash=" . filemtime('mychart.png') . "'>";
filemtime () gets the file modification time.
Tarik Nov 19 '15 at 2:21 2015-11-19 02:21
source share