force a web browser NOT to cache images

Problem

The problem happens when the administrator wants to change the picture. He would just have to hit the “browse” button, pick a new picture and press ok. And this works fine.

Once the image is uploaded, back-end  handles the upload and reloads the form properly.

The problem is that the image shown does not get refreshed. The old image is still shown, even though the database holds the right image. (fact that the IMAGE IS CACHED in the web browser).

Solution:

The problem is random strings can collide. You can use:

<img src="picture.jpg?1222259157.222" alt="">

where “1222259157.222” is the current time on the server.

Leave a Reply

Your email address will not be published. Required fields are marked *