Page 1 of 1
Refresh only one time?
Posted: Thu Jun 03, 2004 3:54 am
by kevin7
hmm.. is that we can make a page refresh only one time?..
actually... what i hving is... after i upload a new image, the webpage still showing the old one... so, i've to refresh it for display the new...
anyway else besides of refresh can solve this problem?
Posted: Thu Jun 03, 2004 3:59 am
by qads
put the upload code in another page, after uploading, redirect the user back?
or keep it in same page, after uploading, use [php_man]header[/php_man]() to redirect the user.
Posted: Thu Jun 03, 2004 3:59 am
by malcolmboston
Code: Select all
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
This will stop your page from being cache'd and therefore will only show the latest content.
Posted: Thu Jun 03, 2004 4:52 am
by choppsta
The Pragma no cache may work...
What's happening is that the image is being cached by the browser, not the page it's displayed on. To stop this you could try adding a random querystring to the image path to trick the browser into thinking it's a different file..
E.g. <img src="myimage.gif?random=849372543">
The other solution is to write a small PHP script that get's the image and outputs it. Cos PHP pages don't tend to be cached and you can write out your own headers you can force it to refresh. So your image url would look something like..
E.g. <img src="getimage.php?image=imageid">
Posted: Thu Jun 03, 2004 4:53 am
by kevin7
hmm... i've one page for upload...
another page for information...
and another is to view...
so, which page should i put the code?
Code: Select all
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
anyway, i'm also curious to know if possible to refresh one time...

Posted: Fri Jun 04, 2004 12:08 am
by kevin7
anyone? can refresh one time?
Posted: Fri Jun 04, 2004 12:18 am
by Illusionist
YOu can't stop a user from refreshing if thats what your trying to accomplish.
Also, when asking a question, try and use atleast better english than what you are using, so people can understadn what you're saying...
Posted: Fri Jun 04, 2004 3:06 am
by choppsta
Ok, your original question was:
"anyway else besides of refresh can solve this problem?"
To which I have provided two possible solutions to try... Other people have also provided possible solutions..
Your question now appears to be:
"anyone? can refresh one time?"
My intepretation of this is that you want to know if there's a way to force a browser/client to refresh a page. By "one time" I presume you mean you want the client to refresh the page once and then cache the page on subsequent requests.
If the solutions given here are used conditionally after an upload this should do what you are asking.
If you need more help I'd suggest reading up on cache control and how web servers work in general. I think also having an understanding of WHY something is happening is much more important than just HOW to solve it.
Posted: Fri Jun 04, 2004 11:54 pm
by kevin7
ooo...

sorry dude, for my bad english and attitude...
hmm.. ok i ask my question again...
how can i made a page that able to refresh itself after the page is loaded...
i use onload=javascript:history.back(0) in body tag... the page keep refresh infinitely..
and after that, i use meta tag... it also keep refresh infinitely...
so, what i want is, refresh only 1 time after the page is loaded...
did i made myself clear? lol...
Posted: Sat Jun 05, 2004 1:28 am
by Weirdan
Code: Select all
function build_qs($get) {
$ret = '';
foreach($get as $name => $value) {
if(strlen($ret)) $ret .= '&';
$ret .= urlencode($name) . '=' . urlencode($value);
}
return $ret;
}
if( !empty($_GET['refresh_me']) ) {
unset($_GET['refresh_me']);
echo "<meta http-equiv='Refresh' content='3; " . $_SERVER['PHP_SELF'] . '?' . build_qs($_GET) ."' />";
}
echo "Link to refresh once after load: <a href='$_SERVER[PHP_SELF]?refresh_me=1'>Click here</a>";