Welcome to WebmasterWorld Guest from 54.145.208.64

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Browser using cached version of Dymanic Page

How to force the browser to access the page again.

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

5+ Year Member



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

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

5+ Year Member



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

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



those headers will help though it is difficult to find something that will make IE, especially, reload 100% of the time.
4:09 pm on Dec 27, 2006 (gmt 0)

5+ Year Member



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.