Page 1 of 1
Problem with refreshing
Posted: Fri Mar 18, 2005 7:37 am
by wizzard81
Hello,
I made a upload script for images but i have a problem. After the picture is uploaded i bring the user back to the picture index page. But then i see the old picture and i have to refresh. Is this a fix for this because some of my users did not know they have to refresh?
Posted: Fri Mar 18, 2005 8:02 am
by s.dot
after you upload the image, before it is displayed to the page, call a new query to get the newest image or image name
Posted: Fri Mar 18, 2005 8:35 am
by feyd
sounds like a caching problem.. maybe attach random garbage as a query string to the images?
Posted: Fri Mar 18, 2005 8:41 am
by wizzard81
? can you explain
Posted: Fri Mar 18, 2005 8:45 am
by feyd
you use a script to return the images correct? add random data to the query string like so:
Code: Select all
<img src="e;my_image_script.php?id=123&g=12341b43bzasdf87214"e; />
Posted: Fri Mar 18, 2005 8:51 am
by hyper_st8
A good way of getting around the page caching is to use:
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
At the top your page.
I found the information at
http://uk2.php.net/manual/en/function.header.php
Posted: Fri Mar 18, 2005 10:44 am
by wizzard81
strange it still the same with the header at the top
i call my image like this=>
<img border=0 src=images/profiles/<? echo $row_picture["picture"]; ?>
after the picture is uploaded i work this way =>
header("Location: myprofile.php");
can this be the problem?
Posted: Fri Mar 18, 2005 12:20 pm
by hongco
on the same link that hyper gave you, it stated that using the header wouldn't work on image files. Also, that same poster mentioned just exactly what feyd was suggesting

try that.
Posted: Fri Mar 18, 2005 12:37 pm
by anjanesh
hongco wrote:on the same link that hyper gave you, it stated that using the header wouldn't work on image files.
Are you sure abt this ?
I assumed
Code: Select all
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
will never get images from cache.
Im pretty sure abt this because I made a gallery script and it was far faster when I removed the header.
Posted: Fri Mar 18, 2005 1:04 pm
by John Cartwright
anjanesh wrote:
Code: Select all
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
will never get images from cache.
Im pretty sure abt this because I made a gallery script and it was far faster then I removed the header.
correct
Posted: Fri Mar 18, 2005 1:30 pm
by hongco
i had no problem with my gallery script either. it was wizard who had the problem, and the person who experienced the same thing suggested to use some random query. I have not tried that myself
