135956557-Small Three It self-learning group, any IT problem can be discussed together, various service networks and so on
-------------------------------------------------------------------------------
Gzip can speed up the website, the compression ratio can be 80%-40%,apache2 after the version is called Mod_deflate
650) this.width=650; "height=" 166 "src=" http://a4.qpic.cn/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ 85ie2mxoxdrtmccz.8anjzvasupa7lpywupqy1ohqqq!/b/db8baaaaaaaa&ek=1&kp=1&pt=0&bo=zwgmaaaaaaafefs! &t=5&su=0235828625&tm=1490922000&sce=0-12-12&rf=2-9 "width=" 463 "style=" margin:0px;padding:0 px;border-width:0px;border-style:none;vertical-align:top; "Alt=" db8baaaaaaaa&ek=1&kp=1&pt=0&bo= Zwgmaaaaa "/>
No compression
650) this.width=650; "height=" 158 "src=" http://a3.qpic.cn/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ xpdbzhzz2ygoa9helwywxicg45ojoepgfoot1xcbltc!/b/dpyaaaaaaaaa&ek=1&kp=1&pt=0&bo=yqgeaaaaaaafegu! &t=5&su=06126593&tm=1490922000&sce=0-12-12&rf=2-9 "width=" 457 "style=" margin:0px;padding:0px ; border-width:0px;border-style:none;vertical-align:top; "Alt=" dpyaaaaaaaaa&ek=1&kp=1&pt=0&bo= Yqgeaaaaa "/>
The compression is enabled
Two modules to open with deflate
LoadModule Deflate_module modules/mod_deflate.so
LoadModule Headers_module modules/mod_headers.so
The compression ratio can be set 1-9 recommended not too high otherwise it will consume too much CPU
Use DOS to install modules that are not available
Apxs-c-i-a/GAO/HTTPD-2.4.23/MODULES/METADATA/MOD_HEADERS.C
I perform the installation
A automatically adds a loadmodule to the httpd.conf to use the module
C Perform a compilation operation
Configuration items, written directly in HTTP, can be
<ifmodule mod_deflate.c>
Deflatecompressionlevel 9 # The level of compression, presets can use the value of 6, to maintain the consumption of processor performance and Web page compression quality balance.
Setoutputfilter DEFLATE #设置输出过滤器, to enable compression on the output, it is necessary, like a switch, to tell Apache to compress the content transferred to the browser
#AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/x-httpd-php
#AddOutputFilterByType DEFLATE image/*
Addoutputfilterbytype DEFLATE text/* #设置对文件是文本的内容进行压缩, such as text/html text/css Text/plain.
Addoutputfilterbytype DEFLATE application/ms* application/vnd* application/postscript application/javascript Application/x-javascript #对javascript文件进行压缩
Addoutputfilterbytype DEFLATE application/x-httpd-php application/x-httpd-fastphp #对php类型的文件进行压缩.
Setenvifnocase Request_uri. (?: gif|jpe?g|png) $ no-gzip dont-vary #设置不对后缀gif, jpg,jpeg,png picture file is compressed. Note:?: Indicates that the contents of () will not be captured
Setenvifnocase Request_uri. (?: Exe|t?gz|zip|bz2|sit|rar) $ no-gzip dont-vary #同上, is set not to compress files such as Exe,tgz,gz
Setenvifnocase Request_uri. (?:p df|mov|avi|mp3|mp4|rm) $ no-gzip dont-vary #同上就是设置不对pdf, Avi,mp3 and other files to compress
</IfModule>
#设置日志输出!
Deflatefilternote Input Input_info
#声明输入流的byte数量
Deflatefilternote Output Output_info
#声明输出流的byte数量
Deflatefilternote Ratio Ratio_info
#声明压缩的百分比
Logformat ' "%r"%{output_info}n/%{input_info}n (%{ratio_info}n%%) ' deflate
#声明日志格式
Customlog Logs/deflate_log.log Deflate
---------------------------------------------------------------------
This article is from the "11627223" blog, please be sure to keep this source http://11637223.blog.51cto.com/11627223/1911990
Apache-gzip Compression-mod_deflate