`
squall140
  • 浏览: 139305 次
  • 性别: Icon_minigender_1
  • 来自: 天津
社区版块
存档分类
最新评论

mod_gzip:Apache的HTTP压缩优化

 
阅读更多
HTTP压缩对于纯文本内容可压缩至原大小的40%一下,从而提供60%以上的数据传输节约,虽然 WEB服务器会因为压缩导致CPU占用的略微上升,但是可以节约大量用于传输的网络IO。对于数据压缩带来的用户浏览速度提升(让页面符合8秒定律),这 点总体负载5%-10%上升是非常值得的。毕竟通过数据压缩会比通过不规范的HTML代码优化要方便得多。

mod_gzip的安装:

修改Makefile中的 apxs路径:然后make make install

配置:mod_gzip+mod_php
LoadModule gzip_module modules/mod_gzip.so

...
AddModule mod_gzip.c

...
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_minimum_file_size 1000
mod_gzip_maximum_file_size 300000
mod_gzip_item_include file /.htm$
mod_gzip_item_include file /.html$
mod_gzip_item_include file /.php$
mod_gzip_item_include file /.php3$
mod_gzip_item_include mime text/.*
mod_gzip_item_include mime httpd/unix-directory
# mod_gzip的临时工作目录: mkdir /tmp/mod_gzip; chmod -R 777 mod_gzip
mod_gzip_temp_dir /tmp/mod_gzip
mod_gzip_dechunk Yes
mod_gzip_keep_workfiles No
</IfModule>

mod_gzip和mod_php的配合:不要让mod_gzip和mod_php使用同一个临时目录,php_session存放目录可以通过 php.ini设置到session.save_path = /tmp/php_sess

mod_gzip和Resin配合:
从resin的邮件列表上查到的:要让mod_gzip在mod_caucho后加载,否则mod_gzip不起作用
...othr modules
AddModule mod_so.c
AddModule mod_caucho.c
#notice: mod_gzip must load after mod_caucho
AddModule mod_gzip.c
AddModule mod_expires.c
...

配置:mod_gzip + resin
<IFModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk yes
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 3000
mod_gzip_maximum_file_size 300000
mod_gzip_item_include file /.html$
mod_gzip_item_include mime text/.*
mod_gzip_item_include mime httpd/unix-directory
mod_gzip_item_include handler caucho-request
</IFModule>

配置:mod_gzip + mod_proxy 反相代理加速并压缩 IIS
注意要增加缺省的文件编码属性映射。
AddType text/html .asp
AddType text/html .aspx

<IFModule mod_gzip.c>

AddType text/html .asp
AddType text/html .aspx
mod_gzip_on Yes
mod_gzip_dechunk yes
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 3000
mod_gzip_maximum_file_size 300000
mod_gzip_item_include file /.html$
mod_gzip_item_include file /.asp$
mod_gzip_item_include file /.aspx$
mod_gzip_item_include mime text/.*
mod_gzip_item_include mime httpd/unix-directory
mod_gzip_item_include handler proxy-server
</IFModule>

参考资料:

mod_gzip的下载
http://sourceforge.net/projects/mod-gzip/

mod_gzip项目首页
http://www.schroepl.net/projekte/mod_gzip/

Apache2 中的mod_deflate:压缩率比mod_gzip略低
http://httpd.apache.org/docs-2.0/mod/mod_deflate.html

模块化安装 Apache
http://www.chedong.com/tech/apache_install.html

分享到:
评论

相关推荐

    使Apache实现gzip压缩配置

    配置文件中没有开启gzip压缩,apache1.3.x可以用mod_gzip进行优化网页浏览的速度,在apache2中也尝试用mod_gzip,但是配置后确发现网页不能正确显示(空白页),所以改换为mod_deflate。 下面说一下怎样在Apache2下...

    mod_gzip-开源

    mod_gzip是流行的Apache Web服务器的Internet内容加速模块。 它压缩传递给客户端的内容。 无需在客户端上安装任何其他软件!

    控制PHP的输出:缓存并压缩动态页面

    mod_gzip是一个Apache模块,其功能是使用Gzip压缩静态的html页面,遵循IETF标准的浏览器可以接受gzip编码(IE, Netscape等)。mod_gzip可以将页面的下载时间提高4-5倍。我强烈建议你在你的web服务器上使用mod_gzip。...

    Apache httpd 安装module mod_expires、mod_deflate的方法

    编译安装好apache httpd以后,可以继续添加扩展 mod_expires 用于发送header,设置静态文件的过期时间 代码如下: cd httpd-2.2.19/modules/metadata sudo /usr/local/apache2/bin/apxs -i -a -c mod_expires.c sudo ...

    在Mac OS上使用mod_wsgi连接Python与Apache服务器

    一、安装mod_wsgi 3.4: ./configure --with-apxs=/Users/levin/dev/apache2.2.27/bin/apxs --with-python=/usr/bin/python make make install ...编辑extra/httpd-vhosts.conf新建项目并增加gzip压缩

    将你的Apache速度提高十倍的经验分享

    它通过用和gzip一样的压缩算法对apache发出的页面进行压缩,可能的话可以把页面压缩成为原来大小的十份之一。哪,如果10K的页面只要传1K这不就是提速10倍嘛。当然一般网页只可以达到3-6倍。那也很不错。对吧。连...

    PHP程序加速探索之压缩输出gzip

    利用Apache中的mod_gzip模块,我们可以利用gzip的压缩算法来对Apache服务器发布的网页内容进行压缩后再传输到客户端的浏览器。如果是纯文本的内容,效果非常明显,大约可以压缩到原来的30%-40%,使用户的浏览速度...

    将PHP程序中返回的JSON格式数据用gzip压缩输出的方法

    利用apache mod_deflate module 开启gzip 开启方法: sudo a2enmod deflate sudo /etc/init.d/apache2 restart 关闭方法: sudo a2dismod deflate sudo /etc/init.d/apache2 restart 3.设置需要gzip压缩输出的...

    PHP+.htaccess实现全站静态HTML文件GZIP压缩传输(一)

    如何减少流量,最方便的办法就是用Gzip压缩,这个apache的gzip压缩是靠一个叫做zlib的类库和gzip的模块(mod_gzip.c)完成的,这玩意专门有一帮牛人研究,因为gzip本身就大名鼎鼎的,并且具有高压缩率开源的压缩原理,...

    Gzip在apache2中的设置和squid对它的处理

    代码如下: LoadModule headers_module modules/mod_headers.so LoadModule deflate_module modules/mod_deflate.so 设置压缩比率,取值范围在 1(最低) 到 9(最高)之间,不建议设置太高,虽然有很高的压缩率,但是...

    AWStats- 非常好用Apache,vsftp日志分析工具

    * 网站压缩统计表(mod_gzip或者mod_deflate), * 使用的操作系统 (每个操作系统的页数,点击率 ,字节, 35 OS detected), * 使用的浏览器 (每个浏览器的页数,点击率,字节,,每个版本(Web, Wap、媒体浏览:97浏览、大于450...

    mod_trace_output-开源

    一个 Apache 模块,允许将发送到浏览器的内容存储在磁盘上的文件或 MySQL 数据库中。它适用于静态和动态页面。 还对存储的内容进行 gzip 压缩,并将其发送给支持它的浏览器。

    使用Awstats分析Nginx的访问日志.doc

    • 网站压缩统计表(mod_gzip 或者 mod_deflate), • 使用的操作系统 (每个操作系统的页数,点击率 ,字节, 35 OS detected), • 使用的浏览器, • 机器人访问(检测319个机器人), • 蠕虫攻击 (5个蠕虫家族), • 搜索...

    cszcms:具有Codeigniter和Bootstrap的开源CMS(内容管理系统)

    CSZ CMS 带有Codeigniter和Bootstrap的内容管理系统(CMS)... Apache MOD_REWRITE已启用。 PHP cURL已启用。 gZip压缩已启用。 安装说明: 将文件解压缩到“ htdocs”目录或“ public_html”中进行托管(如果要将

Global site tag (gtag.js) - Google Analytics