problem with image refresh (possible solutions included)
Posted: Tue Jul 22, 2003 7:26 am
I am running Apache 1.3.26 and php 4.0.6 in a WinME system, using it for building my php apps. Recently ive been working on a online catalogue e-commerce site which among others has an administration interface through which the administrator can update his products characteristics, including the photos (by uploading the images to the server). When the image file is updated in the mysql database, the administrator can preview the updated product by running a php script which retrieves its charactheristics from the database. My problem is that instead of the updated image, the previous image shows up in the page (the one that is retrieved from the cache) and in order to preview the updated image, the administrator has to refresh the page.
I have tried various alternatives in order to refresh the page programmatically or disable the caching, but none of these work (at least, in my system):
a) by sending a http header to disable the caching (one of the following lines)
(got these from the php manual). Here, the browser still gets the image from the cache.
b) by using javascript to refresh the page programmatically:Here, the browser takes forever to output the page
c) by using meta tags with "refresh" attribute, but the browser gets stuck in an endless loop because the page refreshes indefinitely.
d) by using the javascriptmethod but nothing happens.
Finally, I just used a prompt for the administrator that tells him/her to refresh the page, but I would like to end up with a better "coding" solution.
Would you think that one of these methods would work in a real Apache server or is there another solution ? I appreciate any help, Vasilis
I have tried various alternatives in order to refresh the page programmatically or disable the caching, but none of these work (at least, in my system):
a) by sending a http header to disable the caching (one of the following lines)
Code: Select all
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");b) by using javascript to refresh the page programmatically:
Code: Select all
<SCRIPT LANGUAGE="JavaScript">
<!--
location.href="admin_preview_prd_type.php?<?=$QUERY_STRING?>";
-->
</SCRIPT>c) by using meta tags with "refresh" attribute, but the browser gets stuck in an endless loop because the page refreshes indefinitely.
d) by using the javascript
Code: Select all
reload(true)Finally, I just used a prompt for the administrator that tells him/her to refresh the page, but I would like to end up with a better "coding" solution.
Would you think that one of these methods would work in a real Apache server or is there another solution ? I appreciate any help, Vasilis