mod_deflate
模块提供了DEFLATE
输出过滤器,允许服务器在将输出内容发送到客户端以前进行压缩,以节约带宽。
修改httpd.conf
1.使用此模块
LoadModule deflate_module modules/mod_deflate.so
2.在conf文件底下加上
#set deflate modules
#<ifmodule
mod_deflate.c>
#DeflateCompressionLevel
9
#设置压缩率
#AddOutputFilterByType DEFLATE text/html text/plain text/xml
application/x-httpd-php
#AddOutputFilter DEFLATE css js
#</ifmodule>
#以上设置,经过测试后感觉不太好,没有对css和js文件进行压缩。
<location />
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain
text/xml
AddOutputFilter DEFLATE
css
#压缩css文件
AddOutputFilter DEFLATE
js
#压缩js文件
#BrowserMatch ^Mozilla/4 gzip-only-text/html
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
#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$ no-gzip dont-vary
#SetEnvIfNoCase Request_URI .(css|js)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</location>
DeflateFilterNote Input
input_info
#设置日志输出!
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)'
deflate
CustomLog logs/deflate_log.log deflate
以下是日志输出 deflate_log.log
:
"GET /23413 HTTP/1.1" 206/268 (76%)
"GET /123 HTTP/1.1" 205/266 (77%)
"GET /favicon.ico HTTP/1.1" 209/274 (76%)
"GET / HTTP/1.1" 75/73 (102%)
"GET /new/index.jsp HTTP/1.1" 6155/27871 (22%)
"GET /new/css/index1.css HTTP/1.1" 2028/7958 (25%)
"GET /new/css/fonts.css HTTP/1.1" 212/279 (75%)
"GET /js/include.js HTTP/1.1" 2106/5425 (38%)
"GET /new/js/inc.js HTTP/1.1" 1264/3983 (31%)
"GET /search/js/search.js HTTP/1.1" 356/730 (48%)
"GET /search/js/selectarea.js HTTP/1.1" 27757/168335 (16%)
"GET /new/images/new/new_02.gif HTTP/1.1" -/- (-%)
"GET /new/images/new/new_16.gif HTTP/1.1" -/- (-%)
"GET /new/images/new/new_11.gif HTTP/1.1" -/- (-%)
"GET /new_iflogin?tt=1195799219343 HTTP/1.1" 4/2 (200%)
"GET /new/images/bian1.gif HTTP/1.1" -/- (-%)
"GET /new/js/5adpics.js HTTP/1.1" 1068/3845 (27%)
"GET /new/images/1.jpg HTTP/1.1" -/- (-%)
"GET /new/images/userimg_03.gif HTTP/1.1" -/- (-%)
"GET /new/images/4.jpg HTTP/1.1" -/- (-%)
可以看到除了图片jpg格式文件外,其他的jsp,css,js 等都进行了压缩处理!
分享到:
相关推荐
通过讲解gzip源码,对zip领域的流行算法-deflate 进行深入的分析,本文是目前迄今为止可以找到的对deflate分析得较好一篇文章。
ppp_deflate.c - interface the zlib procedures for Deflate compression and decompression (as used by gzip) to the PPP code.
Apache httpd 安装module mod_expires、mod_deflate的方法,需要的朋友可以参考下。
Js算法 zip_deflate(压缩)与zip_inflate(解压),
冰箱行业分析报告_deflate.doc
mod_deflate mod_dir mod_disk_cache mod_dumpio mod_echo mod_env mod_example mod_expires mod_ext_filter mod_file_cache mod_filter mod_headers mod_ident mod_imagemap mod_include mod_info mod_isapi mod_...
Functions to compress according to the DEFLATE specification, using the squeeze LZ77 compression backend.
zip_deflate压缩易语言源码 天哥软件
文件中给出了 gzip主要压缩算法 实现包括 gzip zip deflate 等程序
LoadModule deflate_module modules/mod_deflate.so LoadModule log_config_module modules/mod_log_config.so LoadModule log_forensic_module modules/mod_log_forensic.so LoadModule logio_module modules/mod_...
众所周知,在HTTP1.1中支持gzip压缩,这样可以缩小页面的容量从而加快页面的显示速度。可以使用这个在线的HTTP压缩测试工具来检测一下你的站点是否开始了gzip压缩。 Apache默认的http.conf配置文件中没有开启gzip...
heroku_rails_deflate Heroku Cedar堆栈没有资产服务器(例如Varnish或nginx)前置,并且没有自动配置将gzip压缩用于HTTP传输。 同时,Rails 3.2资产管道花费大量CPU周期来创建所有静态资产的高度压缩版本。 最好...
LoadModule deflate_module modules/mod_deflate.so LoadModule filter_module modules/mod_filter.so 注意:也可以把三个模块放到/etc/httpd/conf/httpd.conf文件里,模块只能在一个文件中加载 设置压缩规则 vim ...
.DEFLATE_Compressed_Data_Format_Specification_version
libdeflate, 用于 DEFLATE/zlib/gzip 压缩和解压缩的优化库 概述libdeflate是一个用于快速整个缓冲区压缩压缩和解压缩的库。支持的格式包括:DEFLATE ( 原始)zlib ( 带zlib包装的。k 。DEFLATE )gzip ( 一个带有gzip...
mod_layer7是Apache 2.2.x的应用程序切换和负载平衡模块。 该模块利用mod_proxy,mod_deflate和mod_cache并包含嵌入式Perl解释器,该解释器支持请求重写和其他有趣的功能。
流浪灯 这是一个基于 Ubuntu 的 LAMP(Linux-Apache-MySQL)服务器... apache2::mod_deflate apache2::mod_expires apache2::mod_headers apache2::mod_env apache2::mod_setenvif apache2::mod_alias apache2::m
判断开始 (size ) send_data = send_data + { 0 } send_data [2] = 位或 (十六进制 (“80”), size) .判断 (size 十六进制 (“10000”)) t = htons (size) send_data = send_data + { 254 } + 指针到字节集 ...