Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Updating a page strictly every minute (PHP, Perl)

For the Clock exercise that I mentioned in my last entry, I need to update the page once a minute. Exactly once a minute. At the start of the minute.

I'm using client pull, where the browser asks for the next page - so my basic request is:
<meta http-equiv="refresh" content="60; url=/clock/now.php">
but that will neither refresh at the start of the minute, nor be exact - with update times and delays taken into account, a handful of times in each hour will be missed out (I know this - I tried it) as the 60 seconds starts from the time the new page is received, not from the previous page.

So I have adjusted the time as follows:
$togo = 61 - date("s");
if ($togo < 15) $togo = 15;

to calculate how long before we trigger - it's going to trigger 1 second into the next minute, and will be selfcorrecting to allow for page transmission times. The business with the "15" is to ensure that initial pages display for at least 15 seconds, even if - by rights - they should be refreshed quicker. That will help avoid an irritating refresh. And the client pull instruction becomes:
<meta http-equiv="refresh" content="<?= $togo ?>; url=/clock/now.php">



The example above is "Client Pull". There's also a complete "Server Push" example, written in Perl, using the same algorithm available for you here
(written 2007-05-14 14:11:39)

 
Associated topics are indexed under
H112 - PHP - Further Web Page and Network Handling
P404 - Perl - Extending Flexibility Using CGI
P406 - Perl - More CGI Programs and Facilities
Q110 - Object Orientation and General technical topics - Programming Algorithms
W502 - Web and Intranet - HTML Document Anatomy
W511 - Web and Intranet - Further Aspects

Back to
Two new pages / sites
Previous and next
or
Horse's mouth home
Forward to
What shape is your shake?
Some other Articles
Smart English Output - via PHP and Perl ? : operator
Save the Forum - A regular clean sweep
Meet, greet and welcome
What shape is your shake?
Updating a page strictly every minute (PHP, Perl)
Two new pages / sites
Themes for the web site
Finding resources - some pointers
Improving searches - from OR to AND?
Painting a masterpiece in PHP
2258 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2009: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho