1 1 Vote

PHP: Force Reload of Image or other Content

Question by Anja Proggy | 29/06/2014 at 22:34

On my website, I am using an image that is created dynamically. I know that it is a good thing to cache images and other content - but the good this behavior is for the performance, the obstructive it is to me with this dynamic image.

Again and again, an old image loaded from the browser cache is shown on my website instead of the current version that is up-to-date.

How is it possible to achieve, that this individual image (or any of the content) will be refreshed with every page impression independent from any cached content?


Stefan Trost

Show Profile | Message
1Best Answer
3 Votes

Just attach a dynamic "version number" to the image URL. So, for example, something like this :

echo '<img src="img.png?t='.time().'">';

With t=time() at the end of the URL, the browser is lead to believe, that it is always another image, because the time created with time() is always different with every site view.

Of course, you do not have to parse or use of the parameter "t" in any way, you are just presenting the image you would like to show.
30/06/2014 at 12:08

ReplyPositive Negative

Related Topics

Force Smartphone to use LTE
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.