homepage Welcome to WebmasterWorld Guest from 54.226.235.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Browser using cached version of Dymanic Page
How to force the browser to access the page again.
Jeremy_H




msg:3200472
 2:49 am on Dec 27, 2006 (gmt 0)

I have a javascript voting system along that looks like this:

function rate(score){
bug=new Image();
bug.src="/score.php?score="+score;
return false;
}

Every time the script opens the score.php page, a MySQL table updates itself with the new score.

The problem is, if a user has ever voted, their vote is not always counted if they vote the same score again.

I'm pretty confident this is because the browser is using a cached version of the score.php page, and not requesting the page again.

How can I ensure the browser will always access the link, even if it has already been cached?

Right now the score.php is a blank page. I'm wondering about maybe adding some headers to the page, or something.

Any suggestions?

Thanks

 

Jeremy_H




msg:3200499
 3:35 am on Dec 27, 2006 (gmt 0)

I've found some headers I might want to add:

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");

Might someone know if this sufficient, insufficient, or redundant?

Thanks

jatar_k




msg:3200828
 2:55 pm on Dec 27, 2006 (gmt 0)

those headers will help though it is difficult to find something that will make IE, especially, reload 100% of the time.

Jeremy_H




msg:3200887
 4:09 pm on Dec 27, 2006 (gmt 0)

Thanks.

Considering IE was the source of all the problems, I amended a line of my JS code to:

bug.src="/score.php?score="+score+"&seed="+Math.random();

Having tested it out, it works pretty well, I just don't had hoped I didn't have to go that route.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved