"Meta Refresh"
Posted: Wed 29 May 2013 5:53 am
Have posted tis in the WX forum as well in response to a Q there.
I wanted to synchronise page refresh(es) to updates.
e.g. Tags updating every 10 mins, or in the case of the vueconsoleCU script, the forecast updating every hour.
After much Googling and coming up empty I tried a few things and found what I feel is the 'key'
The number of seconds can be delivered in a variable.
An expample of one use I have for it is to refresh a script just after the hour so regardless of when a script is accessed, the next refresh will occur just after the hour.
Scenario:- The Davis Vue Console only updates the forecast (for Saratoga, $vpforecasttext) hourly on the hour so there is no point refreshing a script more often than once per hour where all the other changes arrive via 'realtime' and the script displays those changes via javascript.
However the refresh should take place when fresh data is available.
This snippet of code produces a refresh ~30 secs after the hour and every hour thereafter as long as the script stays open.
It is placed in the head section straddling the closing ?> typical in many Saratoga scripts; So anything the script can do (ahead of the "meta refresh") to change $refresh will apply to the next "meta refresh"
Disclaimer for those who are pedantic about accreditation:- I don't claim this to be original in the sense it has not been done before but is "all my own work"
.
Enjoy
I wanted to synchronise page refresh(es) to updates.
e.g. Tags updating every 10 mins, or in the case of the vueconsoleCU script, the forecast updating every hour.
After much Googling and coming up empty I tried a few things and found what I feel is the 'key'
The number of seconds can be delivered in a variable.
An expample of one use I have for it is to refresh a script just after the hour so regardless of when a script is accessed, the next refresh will occur just after the hour.
Scenario:- The Davis Vue Console only updates the forecast (for Saratoga, $vpforecasttext) hourly on the hour so there is no point refreshing a script more often than once per hour where all the other changes arrive via 'realtime' and the script displays those changes via javascript.
However the refresh should take place when fresh data is available.
This snippet of code produces a refresh ~30 secs after the hour and every hour thereafter as long as the script stays open.
It is placed in the head section straddling the closing ?> typical in many Saratoga scripts;
Code: Select all
$refresh = 3630 - (date("i")*60 + date("s")); // 1hr + 30 seconds - seconds past the hour
?>
<meta http-equiv="refresh" content="<?php echo $refresh; ?>" />Disclaimer for those who are pedantic about accreditation:- I don't claim this to be original in the sense it has not been done before but is "all my own work"
Enjoy