


发现nginx配置gzip,压缩css,不压缩js,原来是不压缩临界值,大于1000K的才压缩导致没有被gzip压缩。_html/css_WEB-ITnose
背景:发现并没有压缩,查来查去是这个配置有问题写成1000k了,也就是下面这些列表都不符合条件,不给gzip压缩,gzip_min_length 1k; 不压缩临界值,大于1K的才压缩,一般不用改,被修改成1000k了,于是没有压缩,查了老半天content-type,都写了,呵呵。
修改后,在这儿测试了一下,果然压缩了:
http://pagespeed.webkaka.com/youhua/gzip/
网址 http://www.justwinit.cn/template/trielegant/styles.css 的检测结果:
是否压缩 是
压缩类型 gzip
原文件大小 8704 字节
压缩后文件大小 4275 字节
压缩率 50.88%
图片是否需要启用GZip压缩?
无意间看到有网友提及,图片不用GZip压缩的。图片尽量不要使用gzip,因为gif,png等图片本身就是被压缩过的,
开启和关闭图片GZip压缩后,网页的总体积是不同的,令人惊讶的是开启图片GZip压缩后,网页总体积竟然变大了。而耗时也相应的增多了。
===========================================
1、Vim打开Nginx配置文件
vim /usr/local/nginx/conf/nginx.conf
2、找到如下一段,进行修改
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
3、解释一下
第1行:开启Gzip
第2行:不压缩临界值,大于1K的才压缩,一般不用改
第3行:buffer,就是,嗯,算了不解释了,不用改
第4行:用了反向代理的话,末端通信是HTTP/1.0,有需求的应该也不用看我这科普文了;有这句的话注释了就行了,默认是HTTP/1.1
第5行:压缩级别,1-10,数字越大压缩的越好,时间也越长,看心情随便改吧
第6行:进行压缩的文件类型,缺啥补啥就行了,JavaScript有两种写法,最好都写上吧,总有人抱怨js文件没有压缩,其实多写一种格式就行了
第7行:跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding",我不需要这玩意,自己对照情况看着办吧
第8行:IE6对Gzip不怎么友好,不给它Gzip了
上面摘自:http://www.veryhuo.com/a/view/51706.html
http://www.webkaka.com/blog/archives/how-to-set-gzip-for-js-in-Nginx.html
https://segmentfault.com/q/1010000000585128
查询是否被zip压缩:
http://pagespeed.webkaka.com/youhua/gzip/
输入:
http://www.justwinit.cn/images/js/common.js?jsver=2.1.1.3626.3
=======================================
启用Gzip 可减少 54.2 KB 启用服务器Gzip,可以减少传输字节数。更多 -3分
未启用Gzip的资源有:
http://www.justwinit.cn/template/trielegant/styles.css (大小: 8.5 KB 预计可减少 5.9 KB )
http://www.justwinit.cn/images/js/common.js?jsver=2.1.1.3626.3 (大小: 20.3 KB 预计可减少 14.8 KB )
http://www.justwinit.cn/lang/zh-cn/jslang.js?jsver=2.1.1.3626.3 (大小: 3.7 KB 预计可减少 2.1 KB )
http://www.justwinit.cn/images/js/ajax.js?jsver=2.1.1.3626.3 (大小: 7.4 KB 预计可减少 6.0 KB )
http://www.justwinit.cn/images/js/swfobject.js?jsver=2.1.1.3626.3 (大小: 6.4 KB 预计可减少 4.2 KB )
http://www.justwinit.cn/images/css/SyntaxHighlighter.css (大小: 3.6 KB 预计可减少 2.5 KB )
http://justwinit.cn/favicon.jpg (大小: 1.9 KB 预计可减少 793 B )
http://js.users.51.la/4950674.js (大小: 1.9 KB 预计可减少 1.1 KB )
http://www.justwinit.cn/images/hl/shCore.js (大小: 9.5 KB 预计可减少 5.7 KB )
http://www.justwinit.cn/images/hl/shBrushPhp.js (大小: 3.7 KB 预计可减少 2.1 KB )
http://www.justwinit.cn/images/hl/shBrushJScript.js (大小: 937 B 预计可减少 437 B )
http://www.justwinit.cn/images/hl/shBrushJava.js (大小: 1.0 KB 预计可减少 494 B )
http://www.justwinit.cn/images/hl/shBrushSql.js (大小: 1.9 KB 预计可减少 964 B )
http://www.justwinit.cn/images/hl/shBrushCss.js (大小: 4.0 KB 预计可减少 2.2 KB )
http://www.justwinit.cn/images/hl/shBrushCpp.js (大小: 2.7 KB 预计可减少 1.4 KB )
http://www.justwinit.cn/images/hl/shBrushPython.js (大小: 4.7 KB 预计可减少 2.5 KB )
http://www.justwinit.cn/template/trielegant/images/logo_header.png (大小: 5.6 KB 预计可减少 237 B )
http://www.justwinit.cn/template/trielegant/images/long.gif (大小: 924 B 预计可减少 358 B )
http://justwinit.cn/template/trielegant/images/bridge-banner-eleven.jpg (大小: 18.9 KB 预计可减少 354 B )
http://icon.51.la/icon_0.gif (大小: 846 B 预计可减少 101 B )
http://eiv.baidu.com/hmt/icon/21.gif (大小: 1.1 KB 预计可减少 69 B )

HTML is not only the skeleton of web pages, but is more widely used in many fields: 1. In web page development, HTML defines the page structure and combines CSS and JavaScript to achieve rich interfaces. 2. In mobile application development, HTML5 supports offline storage and geolocation functions. 3. In emails and newsletters, HTML improves the format and multimedia effects of emails. 4. In game development, HTML5's Canvas API is used to create 2D and 3D games.

TheroottaginanHTMLdocumentis.Itservesasthetop-levelelementthatencapsulatesallothercontent,ensuringproperdocumentstructureandbrowserparsing.

The article explains that HTML tags are syntax markers used to define elements, while elements are complete units including tags and content. They work together to structure webpages.Character count: 159

The article discusses the roles of <head> and <body> tags in HTML, their impact on user experience, and SEO implications. Proper structuring enhances website functionality and search engine optimization.

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

Article discusses specifying character encoding in HTML, focusing on UTF-8. Main issue: ensuring correct display of text, preventing garbled characters, and enhancing SEO and accessibility.

The article discusses various HTML formatting tags used for structuring and styling web content, emphasizing their effects on text appearance and the importance of semantic tags for accessibility and SEO.

The article discusses the differences between HTML's 'id' and 'class' attributes, focusing on their uniqueness, purpose, CSS syntax, and specificity. It explains how their use impacts webpage styling and functionality, and provides best practices for


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

WebStorm Mac version
Useful JavaScript development tools
