新闻中心

优化ecshop让首页“真”静态

作者 / 无忧主机 时间 2015-12-07 11:42:29

很多ecshop用户在php空间做商城网站的时候,往往应为首页的商品太多,导致图片加载时间过长而无法马上打开,这样很容易使客户体验度下降,如果我们将首页静态话,这样肯定能提高用户的体验度。 那如何才能解决这样的问题呢?很多站长们都是用伪静态,今天小编教大家另外一个方法-------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部分 无忧主机相关文章推荐阅读: ECSHOP退出登录后会清空购物车的BUG优化 如何在ECSHOP后台管理的时候显示扩展分类 ECSHOP程序最常见的数据库缓存报错和程序缓存报错解决方法总结

本文地址:https://www.51php.com/ecshop/21060.html

1
1
1
1
1
1
1

客户服务热线

0791-8623-3537

在线客服