zoukankan      html  css  js  c++  java
  • Nginx开启Gzip压缩大幅提高页面加载速度

    [root@12 conf]# vi nginx.conf
    
            gzip on;#开启GZIP
            gzip_min_length  1k; #不压缩临界值,大于1K的才压缩,一般不用改
            gzip_buffers     4 16k;
            #gzip_http_version 1.0;
            gzip_comp_level 2;#压缩级别,1-10,数字越大压缩的越好,时间也越长
            #gzip_types       text/plain application/x-javascript text/css application/xml;
             gzip_types       text/plain application/x-javascript text/css application/xmli text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    
            gzip_vary off;
            gzip_disable "MSIZE [1-6].";#IE6对Gzip不怎么友好,不给它Gzip
    
    service nginx reload
    [root@12 conf]# curl -I -H "Accept-Encoding:gzip,deflate" "http://xinxianm.com"
    HTTP/1.1 200 OK
    Server: nginx/1.4.4
    Date: Tue, 31 May 2016 01:01:45 GMT
    Content-Type: text/html; charset=utf-8
    Connection: keep-alive
    X-Powered-By: PHP/5.5.7
    Set-Cookie: ECS_ID=650aa6ce6b78e9803c78923affc6a98ad5cf9bd2; path=/
    Cache-control: private
    Content-Encoding: gzip
    
    [root@12 conf]# curl -I -H "Accept-Encoding:gzip,deflate" "http://xinxianm.com/images/upload/Image/1_05%2875%29.jpg"
    HTTP/1.1 200 OK
    Server: nginx/1.4.4
    Date: Tue, 31 May 2016 01:02:46 GMT
    Content-Type: image/jpeg
    Last-Modified: Tue, 12 Apr 2016 07:24:20 GMT
    Connection: keep-alive
    Expires: Thu, 30 Jun 2016 01:02:46 GMT
    Cache-Control: max-age=2592000
    Content-Encoding: gzip
    
  • 相关阅读:
    java private修饰的类和变量
    Volatile和Synchronized对可见性和原子性的支持
    Socket套接字
    Spring MVC请求执行流程
    Spring AOP术语解释
    equals()和==的区别
    约瑟夫环之递归算法
    数据库特性之原子性和一致性
    设计模式之单例模式
    平衡二叉树的插入旋转
  • 原文地址:https://www.cnblogs.com/bass6/p/5544733.html
Copyright © 2011-2022 走看看