控制台结果为乱码
说明配置压缩网站的信息成功,此法可能对服务器cpu有些损耗。
Apache 开启Gzip压缩配置:
去掉以下两个 注释#
LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so
在 httpd.conf最后加入
#apache Gzip <Location /> # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch bMSIE !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/js # Make sure proxies don't deliver the wrong content #Header append Vary User-Agent env=!dont-vary </Location>
设置完成之后 访问http://tool.chinaz.com/Gzips/ 输入你的网站域名 检测压缩情况。









