zoukankan      html  css  js  c++  java
  • nginx媒体压缩

    1 gzip模块

    参考:http://nginx.org/en/docs/http/ngx_http_gzip_module.html

    浏览器的请求头里会表明Accept-Encoding 方式。服务器收到请求,就把内存按格式压缩,发给浏览器,响应头里会说明Content-Encoding和Content-Length。

    The ngx_http_gzip_module module is a filter that compresses responses using the “gzip” method. This often helps to reduce the size of transmitted data by half or even more.

    2 参数

    Syntax: 
    gzip on | off;
    Default: 
    gzip off;
    Context: 
    http, server, location, if in location
    #打开gzip
    

      

    Syntax: 
    gzip_buffers number size;
    Default: 
    gzip_buffers 32 4k|16 8k;
    Context: 
    http, server, location
    #在缓冲区的压缩块的数量和大小。内存页一般是4k,所以设定上一般是32 4k
    

      

    Syntax: 
    gzip_comp_level level;
    Default: 
    gzip_comp_level 1;
    Context: 
    http, server, location
    #设定压缩等级,1-9。推荐6,取压缩率和cpu消耗的最优值
    

      

    Syntax: 
    gzip_disable regex ...;
    Default: 
    — 
    Context: 
    http, server, location
    #不使用gzip的UA设定,一般针对MSIE
    

      

    Syntax: 
    gzip_http_version 1.0 | 1.1;
    Default: 
    gzip_http_version 1.1;
    Context: 
    http, server, location
    #使用gzip的http version。
    #现在都是1.1,这条无需要了。
    

      

    Syntax: 
    gzip_min_length length;
    Default: 
    gzip_min_length 20;
    Context: 
    http, server, location
    #启用gzip的最小传输大小。
    

      

    Syntax: 
    gzip_types mime-type ...;
    Default: 
    gzip_types text/html;
    Context: 
    http, server, location
    #启用gzip的媒体类型,text/html默认压缩,不写也行
    

      

    Syntax: 
    gzip_vary on | off;
    Default: 
    gzip_vary off;
    Context: 
    http, server, location
    #是否在相应头中显示gzip encoding
    

      

    3 一个配置

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     8 32k;
    gzip_comp_level 6;
    gzip_types       text/plain application/x-javascript text/css  application/xml;
    gzip_disable     "MSIE [1-6].";
    gzip_vary on;
    #在nginx.conf的http标签下。所以对所有server和vhost生效。
    

      

  • 相关阅读:
    OD使用教程3(下) 调试篇03|解密系列
    逻辑运算
    windows等级安排
    windows等级安排
    条件跳转指令
    条件跳转指令
    OD使用教程3(中) 调试篇03|解密系列
    OD使用教程3(下) 调试篇03|解密系列
    OD使用教程3(中) 调试篇03|解密系列
    逻辑运算
  • 原文地址:https://www.cnblogs.com/jabbok/p/9248298.html
Copyright © 2011-2022 走看看