ecshop首页是真静态最主要的好处是提升访问速度,首页访问时间就是下载时间,去除了程序响应查询时间。方法很简单。原理是模拟浏览器访问页面,得到html源码,然后输出保存为HTML文件 如果网站访问量比较大,我们可以把ecshop的网站的首页生成html,减小服务器的压力,让ecshop首页打开得更快一点,后台设置效果如图: 实现这个可以按以下两步完成(另外主机这边则应该把index.html的优先访问级别排在index.php前面): 一、打开admin/templates/top.htm <div id="send_info" style="padding: 5px 10px 0 0; clear:right;text-align: right; color: #FF9900;width:40%;float: right;"> {if $send_mail_on eq 'on'} <span id="send_msg"><img src="images/top_loader.gif" width="16" height="16" alt="{$lang.loading}" style="vertical-align: middle" /> {$lang.email_sending}</span> <a href="javascript:;" id="lnkSwitch" style="margin-right:10px;color: #FF9900;text-decoration: underline">{$lang.pause}</a> {/if} <a href="index.php?act=clear_cache" target="main-frame" class="fix-submenu">{$lang.clear_cache}</a> <a href="privilege.php?act=logout" target="_top" class="fix-submenu">{$lang.signout}</a> </div> 修改成 <div id="send_info" style="padding: 5px 10px 0 0; clear:right;text-align: right; color: #FF9900;width:40%;float: right;"> {if $send_mail_on eq 'on'} <span id="send_msg"><img src="images/top_loader.gif" width="16" height="16" alt="{$lang.loading}" style="vertical-align: middle" /> {$lang.email_sending}</span> <a href="javascript:;" id="lnkSwitch" style="margin-right:10px;color: #FF9900;text-decoration: underline">{$lang.pause}</a> {/if} <a href="../_creat_index.php" target="main-frame" class="fix-submenu">生成静态首页</a> <a href="index.php?act=clear_cache" target="main-frame" class="fix-submenu">{$lang.clear_cache}</a> <a href="privilege.php?act=logout" target="_top" class="fix-submenu">{$lang.signout}</a> </div> 增加生成静态页的后台操作链接 二、前台增加生成html的php文件_creat_index.php <?php define('IN_ECS', true); define('INIT_NO_USERS', true); define('INIT_NO_SMARTY', true); require(dirname(__FILE__) . '/includes/init.php'); $site_url = rtrim($ecs->url(),'/'); $index_file = ROOT_PATH . 'index.html'; $source_url = $site_url . '/index.php'; ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)'); file_put_contents($index_file, file_get_contents($source_url), LOCK_EX); ?> 静态首页已经生成<a href="<?php echo $site_url; ?>" target="_blank">浏览首页…</a> 最后记得先删除根目录下规则 index.html部分
|