Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browser won't refresh pictures, uploaded with a script

Status
Not open for further replies.

ecokid

Programmer
May 22, 2000
4
US
I have a question about pictures, uploaded with a script, that don't refresh as expected.&nbsp;&nbsp;On my site, I have pages with a file uploading button, and a copy of the current picture displayed next to it.&nbsp;&nbsp;When I upload a new picture to the same filename, the picture won't refresh unless I rightclick, open the image, and then reload the image.<br><br>I've tried all the tricks to force the PAGES to reload, but the pictures are still drawn off of an old cached copy.&nbsp;&nbsp;<br><br>After doing some investigating online, all I could surmise is that perhaps pictures uploaded with a form are lacking a header that normally has 'last-modified' information.&nbsp;&nbsp;This header is then (I'm guessing) used by the browser to decide whether there's a newer copy on the server.<br><br>Does anyone know anything about such image headers, if they exist (I don't know), and how to add them through a script?&nbsp;&nbsp;Or, does anyone know a better solution? <br><br>Thanks in advance, and feel free to e-mail me directly if it's convenient at <A HREF="mailto:cgi@empowerdesigns.com">cgi@empowerdesigns.com</A>.<br><br>James
 
I've seen many folks use the NOSAVE attribute to prevent browser caching - but according to big-time advertising-delivery services, the most reliable way to prevent caching is to append the IMG SRC url with a &quot;different&quot; query string for the old image and the new one. Cache-busting (as it's called) is quite simple to achieve.

For example, the script that generates the page could call the image as <IMG SRC=&quot;/images/joe.gif?$time&quot;>. The time variable can be generated as:
$time=localtime(time);

For every graphic, it will be appended with a different query string that most browsers will see as a totally new URL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top