Have you experienced this scenario:
You updated an image and uploaded it to your website.
Your friend goes to view the page and it shows the old image still.
You franticly check the code and the file and settings to see what is going on.
The user’s web browser caches (saves) the files it downloads when visiting web pages. The purpose is for if you revisit the page in a short timeframe then it can load the local copy instead of downloading from the server.
I have a trick for you.
We can alter the HTML to force the browser to think the image is a new image every time it loads the page, which in turn causes the image to be downloaded again.
Example code:
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
We can add a fake parameter to the url of the image.
<link rel="icon" type="image/x-icon" href="/images/favicon.ico?random=1234">
Just add a question mark, a variable name (anything you want, I chose random), and assign it a value.
Some people like to do version numbers.
?v=1
?v=2
If you are using a scripting language you can have it populate a random value, my fav being simply the current timestamp.
Meir is a web developer who has been writing code since 2000. He enjoys his family, movies, cooking, golf, and bowling.