Another solution is to set up background refreshing of your cache files. This is done by setting up a "cron job" to periodically load a web page containing the newsfeeds. When setting up such a system, note the following points:
update_news.php
This file is loaded by "trigger_update.php" or "trigger_update.pl", show below,
to cache a copy of the newsfeed on your server for quick access:
your_webpage.php
Now that you have the newsfeed cached on your server, you can access it on the page where you want it displayed like this:
The Cron Job
To trigger update_news.php, you'll need to set up a cron job to execute one of the following two files. The PHP file is simpler, but not all servers will allow you to execute PHP files from cron jobs, and not all PHP installations will allow you to trigger a script this way. If you can't make it work, use trigger_update.pl instead.
Whichever file you use, if your webserver is a UNIX based system (like Linux or xBSD), you'll need to make the file executable. Some FTP programs can do this, or you might log in using SSH or telnet, switch to the folder containing the file, and execute the command "chmod 755 trigger_update.php" (or ".pl").
Refer to the documentation for cron for instructions on how to set up the cron job on your server.
In both cases, the cron job can run on a different webserver from the one that hosts update_news.php. If using trigger_update.pl and running it on a different server, enter the hostname of the computer where the cron job is running in the "$hostname=" line.
trigger_update.php
If necessary, adjust the path on the first line to point to the correct location of "php" on your server. Also change the URL on the fopen line to the URL of update_news.php on your server.
<?php
if ($f=fopen('http://www.yourwebsite.com/path/to/update_news.php','r')) {
while (!feof($f)) fgets($f);
fclose($f);
}
return;
?>
trigger_update.pl
Change "www.yourwebsite.com" (near the top) and "/path/to/update_news.php" (near the bottom) to the appropriate values for your setup. IMPORTANT: The path to update_news.php should NOT be the full path on the server, but the path that a web browser would specify. For example, if a web browser would load the page as http://www.geckotribe.com/rss/update_news.php", the appropriate path would be /rss/update_news.php.
use Socket;
$hostname='www.yourwebsite.com';
$remote_host='www.yourwebsite.com';
$sockaddr = 'S n a4 x8';
$proto=getprotobyname('tcp');
($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($remote_host);
$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, 80, $thataddr);
socket(S, &AF_INET, &SOCK_STREAM, $proto)||die "socket: $!";
bind(S,$this)||die "bind: $!";
connect(S,$that)||die "connect: $!";
select(S); $|=1; select(STDOUT);
print S "GET /path/to/update_news.php HTTP/1.0\nHost: $remote_host\n\n";
while ($line=<S>) { }
close(S);
exit 0;