我一直用Lilina来做RSS的聚合工具, 因为他够简单. 不过在订阅数超过15时访问就比较慢了, 需要改进一下, 最好是生成静态的HTML缓存文件. 在参考了网上其他人的修改后, 形成了我自已的版本, 只需要修改一个index.php文件, 在这儿我将它命名为index_gen.php, 并作了以下修改(红字部份为新增部份):
/* output buffer control start */
$index_file = "index.html";
ob_start("callback");
$rebuild = 0;
if ($_GET['force_cache']=1)
{
$rebuild = 1;
}
function callback($str)
{
global $rebuild, $index_file;
$res = "";
if($rebuild)
{
$fd = fopen($index_file, "w");
fputs($fd, $str, strlen($str));
fclose($fd);
$res=$str;
return $res;
}
else
{
$fd = fopen($index_file, "r");
$res = fread($fd, filesize($index_file));
fclose($fd);
return $res;
}
}
/* Function used to sort rss items in chronological order */
function date_cmp($a, $b) {
在上面的修改中需要将绝对路径写到index_file变量中, 并在index_gen.php后面加上以下几行:
<?php
/* flush output buffer */
ob_end_flush();
?>
改进后用一个crontab来进行调度每一小时刷新一次, 你可以试试看速度, 在这儿我总共订阅了13个Blog, 列出最近60小时内发布的新文章. Crontab如下所示:
1 * * * * wget http://localhost/index_gen.php?force_cache=1 -O - > /dev/null 2>&1