Apache的优化设置&mod_deflate压缩效果分析

1.动态添加php模块

/usr/local/apache2/bin/apxs -i -a -c /usr/local/src/lamp/httpd-2.2.17/modules/metadata/mod_expires.c

/usr/local/apache2/bin/apxs -i -a -c /usr/local/src/lamp/httpd-2.2.17/modules/metadata/mod_headers.c

/usr/local/apache2/bin/apxs -i -c -a /usr/local/src/lamp/httpd-2.2.17/modules/filters/mod_deflate.c

2.修改配置文档

设置缓存时间:很有用

<IfModule mod_expires.c>

ExpiresActive On

ExpiresDefault A60

ExpiresByType application/javascript A2592000

ExpiresByType text/css A604800

ExpiresByType image/* A31536000

ExpiresByType text/plain A604800

ExpiresByType application/x-shockwave-flash A2592000

ExpiresByType video/x-flv A2592000

ExpiresByType application/pdf A2592000

ExpiresByType text/html A900

</IfModule>

开启压缩:

DeflateCompressionLevel 9

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php

AddOutputFilter DEFLATE js css

PDF 、图片、音乐文档之类的这些本身都已经高度压缩格式,重复压缩的作用不大,反而可能会因为增加CPU的处理时间及浏览器的渲染问题而降低性能。所以就没必要再通过Gzip压缩。

压缩前后对比分析:

1.压缩比例为28%

压缩比例为:34% 

 

压缩比例为:22%

 

你可能感兴趣的:(apache)