flushing the cache for just one image?

They have: 21 posts

Joined: Sep 2006

I have updated an image called heart.jpg on my website.

How do I make sure that the new one displays when a user re-visits my website, rather than the old one they have in their cache?

Tks,

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

You might find a way to do this, although it's not worth the effort. I've found that browsers can be reasonably intelligent about using their cache. One way to 'fool' them into updating is use a different filename for the image, then--as long as the browser gets the new version of your page--it will use the new image.

The file name would be something like: heart02.jpg, or heartnew.jpg Hope this helps. Smiling

a Padded Cell our articles site!

He has: 1,758 posts

Joined: Jul 2002

I wonder if this would work:

<img src="filename.jpg?r=<?= time() ?>" with="50" height="50" alt="etc" />'

I used something similar to prevent caching of a dynamically generated css file once and it worked a treat...

Andy

They have: 21 posts

Joined: Sep 2006

Thanks,----- are you calling a function here time() ....is it something in your header?

He has: 11 posts

Joined: Feb 2007

<? time(); ?> is a php function...

If you want to use Javascript you will need to make a function that will either create a random number and attach it to the end of the image, or create an array that will randomly select one to show.

ACJavascripts.com - Free Cut and Paste Javascripts
SimplyProgram.com - Personal Blog
CYWebmaster.com - Webmaster Forum (re-designing)

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.