Refresh only one time?
Moderator: General Moderators
Refresh only one time?
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?
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?
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
Code: Select all
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">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">
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">
hmm... i've one page for upload...
another page for information...
and another is to view...
so, which page should i put the code?
anyway, i'm also curious to know if possible to refresh one time... 
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">-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
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.
"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.
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...
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...
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>";