In order to reduce the pressure of the Tomcat service, the picture on the page using the Windows version of the Nginx load, because some pictures are larger, loading particularly slow, so in Nginx opened the compression function of gzip. Loading pictures is a lot faster.
The "Web gzip compression detection" tool in Webmaster Tools detects images with a compression rate of 69.53%, such as:
The following describes how the nginx.conf file is configured:
1, open the nginx.conf configuration file;
2, find #gzip on this sentence, such as:
3. Change the #gzip on to the following code:
#开启GzipgzipOn ; #不压缩临界值, more than 10K compression, generally do not change gzip_min_length 10k; #设置gzip申请内存的大小, the function is to request memory space in multiples of block size gzip_buffers448k; #用了反向代理的话, end communication is HTTP/1.0, there should be no need to look at me this popular science, there are words to comment on the line, the default is http/1.1gzip_http_version1.0; #压缩级别,1-9, the greater the number of compression of the better, the longer the time, look at the mood casually change it gzip_comp_level6; #设置需要压缩的MIME类型, non-set values are not compressed gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/PNG; #跟Squid等缓存服务有关, on will increase in the header."vary:accept-encoding"gzip_vary off; #IE6对Gzip不怎么友好, don't give it a gzip gzip_disable"MSIE [1-6]\.";
Change to post code such as:
4. Reload Nginx;
<span style="white-space:pre"> </span> restart in Linux:/usr/local/nginx/ Sbin/nginx-s Reload restarts in Windows: C:\server\nginx-1.0. 2>nginx.exe-s Reload
5. Test whether Nginx compression is enabled:
(1). Page successfully compressed
<span style="White-space:pre"> </span>curl-i-H"Accept-encoding:gzip, deflate" "http://wwww.xxxx.com/mr_smile2014"HTTP/1.1 $OK Server:nginx/1.9.1Date:sun, -The - -: -: theGMT Content-type:text/html; charset=utf-8Connection:keep-Alive X-powered-by:php/5.2. 17P1 X-pingback:http://www.slyar.com/blog/xmlrpc.phpContent-encoding:gzip
(2). css file successfully compressed
Curl-i-H"Accept-encoding:gzip, deflate" "Http://wwww.xxxx.com/mr_smile2014/index.css"HTTP/1.1 $Okserver:nginx/1.9.1Date:sun, -The - -: +: -gmtcontent-type:text/Csslast-modified:sun, -The - the: -: -Gmtconnection:keep-Aliveexpires:mon, -The - .: +: -Gmtcache-control:max-age=43200Content-encoding:gzip
(3). Picture successfully compressed
Curl-i-H"Accept-encoding:gzip, deflate" "http://wwww.xxxx.com/1_mr_smile2014.jpg"HTTP/1.1 $Okserver:nginx/1.9.1Date:sun, -The - -: A: $gmtcontent-type:image/Pnglast-modified:thu, atThe - -: -: -Gmtconnection:keep-Aliveexpires:tue, -Sep - -: A: $Gmtcache-control:max-age=2592000Content-encoding:gzip
(4) JS file successfully compressed
Curl-i-H"Accept-encoding:gzip, deflate" "Http://wwww.xxxx.com/mr_smile2014/js/jquery/jquery.js"HTTP/1.1 $Okserver:nginx/1.9.1Date:sun, -The - -: +: -gmtcontent-type:application/x-Javascriptlast-modified:thu, AJul - -: the: $Gmtconnection:keep-Aliveexpires:mon, -The - .: +: -Gmtcache-control:max-age=43200Content-encoding:gzip
Original Sticker Address: 51983447
Open Nginx gzip compression in Windows, Linux greatly improve page, picture loading speed < turn >