how to stop image being cached?

javascript United Kingdom
  • 19 years ago

    Is it possible to prevent a certain image in my page from being cached? I have an image that is updated between loads but when it's cached the browser keep producing the original image. :- (



    Any ideas?


    Thanks


    zVV

  • 19 years ago

    You have a number of options


    1. Configure IIS to automatically expire the content (see http://www.developerfusion.com/show/228/)
    2. Create some javascript to add a random value on the end of the src tag... ie src="images/theimage.gif?randomvalue"
    3. point the src parameter to a server-side script such as php/asp, which adds an Expires header, and then outputs the image

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne