网络上关于开始Gzip压缩的方法介绍的文章还是很多的,这里有一篇写得比较详细,也就不再重复别人已经做过的工作了(猛击此处查看)。这里我采用的是直接修改index.php文件的方法达到压缩效果的,下载index.php文件后在文件中加入ob_start(“ob_gzhandler”);保存之后替换掉源文件即可,修改之后的文件如下所示:
< ?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
ob_start("ob_gzhandler");
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
?>
启用压缩之后可以猛击此处检测压缩效果:
网址 http://h4ck.ws 检测结果如下: | |
---|---|
是否压缩 | 是 |
压缩类型 | gzip |
原始文件大小 | 60337 字节 |
压缩后文件大小 | 16267 字节 |
压缩率(估计值) | 73.04% |
☆文章版权声明☆
* 网站名称:obaby@mars * 网址:https://h4ck.org.cn/ * 本文标题: 《WordPress 开启Gzip压缩》 * 本文链接:https://h4ck.org.cn/2010/12/wordpress-gzip/ * 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。
分享文章: