zqfleaf

zencart 对首页静态化处理

今天有一朋友抱怨自己的网站访问速度太慢,或有时快有时慢。客人点了后,打不开就走了。

解决方法,一般有,看一下服务器的带宽,服务器上网站的数量。给图片瘦身。

在这些都没有办法再改进的情况下,只能想让首页静态化,提高首页的访问速度,尽可能留一些客户。

第一步:

用一个程序,手动生成静态页面。

<?php

                ob_start();     
                @readfile("http://www.yourdoname.com/");     
	$string = ob_get_flush(); 
	$myfile = fopen("myfile.html","w");     
	fwrite($myfile,$string);     
	ob_clean();
?>

上面的yourdoname要改成自己的域名。

第二步:再index.php开头加入以下代码

	if (!isset($_SESSION) && empty($_GET) && empty($_POST)){
	$file_handle = fopen("http://www.yourdoname.com/myfile.html","r");   
	while (!feof($file_handle)) {
		 $line = fgets($file_handle);
		 echo $line;
	}
	fclose($file_handle);
	exit(0);
}

这样试一下,在本机速度都快很多。

posted on 2010-06-04 16:06  Hunter II  阅读(615)  评论(2编辑  收藏  举报

导航