一直想加快PHP168系统首页的显示速度,现在终于可以如愿了。方法如下。
一,对原来的首页动态index.php文件进行改造,代码如下:
<?php
ob_start(); //首页生成静态的htm,在开始处加入 ob_start(),打开缓冲区
//---
require_once('./global.php');
if($webdb[indexhtml]>0){ //生成静态,
header("location:index_tpl.php?type=1");
}
if( file_exists(PHP168_N."template/$stylefile/index.php") ){ //功能扩展
require_once(PHP168_N."template/$stylefile/index.php");
}else{
require_once(PHP168_N."template/php168/index.php");
}
require_once(html("css"));
require_once(html("head"));
require_once(html("index"));
require_once(PHP168_N."foot.php");
//-----
$temp = ob_get_contents(); //得到缓冲区的内容并且赋值给变量$temp
本文来自织梦
ob_end_clean();
//写入首页index.htm文件
$fp = fopen('index.htm','w'); //打开要写的文件指针
fwrite($fp,$temp); //写信息到文件
fclose($fp); //关闭文件指针
//调用首页index.htm文件
if(file_exists('index.htm')){
header("location:index.htm");
}
?>
二,对httpd.conf文件进行索引修改(注意:WAPM系统要修改vhost.conf文件):
找到DirectoryIndex 把index.php 放在最前面即:
DirectoryIndex index.php index.htm index.html
把index.php放在最前面才能自动更新页面。 本文来自织梦
dedecms.com
dedecms.com
更多精彩:http://www.cnseoo.net www.hbmobiles.cn

