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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image refresh

Status
Not open for further replies.

hz

Programmer
Oct 2, 2000
29
US
Hi, all:

I am using PHP & its gd extension to draw graphs, it works fine, except this one big problem: Each time the graph is generated by user submitted data, but the browser(esp. NE) won't display the newest version, it just displays the cached one, so even the images are changed, the browser would just display the same first one, unless you manually refresh it.

I am wondering if someone else ran into the same situation and could give me some ideas on how to fix that.

Thanks. [sig][/sig]
 
Thanks rycamor for the reference.

However, my situation is a little different. I used the "meta" tag to do cache control and refresh, both will eat user input, so there will be no image generated. What I need at least is some code to generate a html or php page, each time the page is opened after one auto refresh.
 
Just venturing a guess here:

When generating the graphic on the server, why not give it a unique name (there's a uniqid() function for this)... In the returned html page, for the content refresh line, use a location like &quot;some.php?oldimage=imagename&quot; where imagename comes from the <img src=> tag and on the refresh, the program will unlink that oldimage, create a new one with a new name and change the <img src=> tag appropriately.

brendanc@icehouse.net
 
Thanks for the idea, sophisticate!

I actually used time stamp idea to name the image, so now there is no refresh problem. However, another problem comes out: If a user issued many query, there would be many images stored in the server's folder, so I put some code to delete the older one each time a new image is generated. This way only one image will be stored at the server forever. What if many users process the query at the same time? I don't know how the server(NT+apache) will handle these file operations? Will the system lock the file access while another query is drawing an image? Or race situations occur and the program will crash beacuse of deadlock or produce wrong images?
Any ideas?
 
Hi,
I have the same problem :(. This is my header, but it stille uses the image from the cache:

<?php
header(&quot;Expires: Mon, 26 Jul 1997 05:00:00 GMT&quot;); // Date in the past
header(&quot;Last-Modified: &quot; . gmdate(&quot;D, d M Y H:i:s&quot;) . &quot; GMT&quot;); // always modified
header(&quot;Cache-Control: no-store, no-cache, must-revalidate&quot;); // HTTP/1.1
header(&quot;Cache-Control: post-check=0, pre-check=0&quot;, false);
header(&quot;Pragma: no-cache&quot;); // HTTP/1.0
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top