Refresh Images Once

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I've done hours of research but I can't seem to find an answer to a
very simple problem.

I have a catalog site where a user can upload an image for a certain
product.  He/she edits the product by uploading a different image.
The problem is that the image is being cached and it doesn't get
refreshed unless a user manually refreshes his/her browser.

I've tried HTTP headers, Meta tags, htaccess and javascript.  How are
you guys doing this?  The text of the product (stored in a db) changes
but the image (stored in a directory) doesn't.

I've read of spoofing the url so it's different each time.  I rather
not set no-cache to the entire page because it would slow down
searches.  I just need the images to be refreshed.

Re: Refresh Images Once

Quoted text here. Click to load it

I can't remember where I heard this, but I seem to remember that if you add
a question mark to the end of the image source, the browser will not cache
it.  ie.

<img src="item0001.jpg?" />

Can anyone else verify this?

Chris Finke

Re: Refresh Images Once

Quoted text here. Click to load it
I remember the same, but with a random number on the end

<img src="item0001.jpg?1234567890">

That way the browser sees a different number each time (well by law of
averages).  You could use time ?hhmmss


Re: Refresh Images Once

Nel wrote:

Quoted text here. Click to load it
Better yet, with the webcam thing I made once, I used the time() to
create a number. That way it's different every time..

Re: Refresh Images Once

Thanks guys. Adding '?'.time() did the trick.

Site Timeline