zoukankan      html  css  js  c++  java
  • nginx 的提升多个小文件访问的性能模块

    阿里开源的第三方模块下载地址:https://github.com/alibaba/nginx-http-concat

    下载模块

     git clone  https://github.com/alibaba/nginx-http-concat.git
    

     编译进nginx里

    cd nginx-1.15.9/
    使用--add-module=参数指定第三方模块路径
     ./configure --prefix=/data/web --sbin-path=/usr/bin --user=nginx --group=nginx --with-http_stub_status_module --with-http_auth_request_module --add-module=/root/nginx-http-concat
    make 主
    cp ~/nginx-1.15.9/objs/nginx /usr/bin/  把可执行文件复制指定目录,备份之前可执行文件
    

      配置

    server {
    	server_name concat.com;
    	error_log logs/concat_error.log debug;
    	concat on;  #是否启用
    	root html;
    	location /concat {
    		concat_max_files 30; # 定义可在给定上下文中连接的最大文件数。请注意给定的URI不能大于平台的页面大小。在Linux上,您可以获得页面大小发布:
    		concat_types text/plain text/css text/html;#定义可在给定上下文中连接的MIME类型
    		concat_unique on;#定义是否只能连接给定MIME类型的文件,或者是否可合并多类型。例如,如果off 在给定的上下文中设置为then,则可以连接Javascript和CSS文件。请注意,默认值为on,意味着只有具有相同MIME类型的文件在给定上下文中连接。所以,如果你有CSS和JS,你不能做这样的事情:为了做到这一点,你必须设置concat_unique off。这适用于您决定通过添加相应的MIME类型来连接的任何其他类型的文件concat_types,
    		concat_delimiter ':::'; #定义两个文件之间的分隔符。如果配置为concat_delimiter“ n”,则当访问http://example.com/??1.js,2.js时,将在1.js和2.js之间插入' n'。
    		concat_ignore_file_error on;#是否忽略404和403。
    	}
    }  

        网页

    [root@python html]# mkdir concat
    [root@python html]# cd concat/
    [root@python concat]# echo "1.txt" > 1.txt
    [root@python concat]# echo "2.txt" > 2.txt
    [root@python concat]# echo "2.css" > 2.css
    [root@python concat]# echo "1.css" > 1.css
    

      

    测试

    [root@python vhast]# curl www.concat.com/concat/??1.css,2.txt,2.css,1.txt
    1.css
    :::2.txt
    :::2.css
    :::1.txt
    [root@python vhast]# curl www.concat.com/concat/??1.css,2.txt,1.txt
    1.css
    :::2.txt
    :::1.txt
    [root@python vhast]# curl www.concat.com/concat/??1.txt,2.txt
    1.txt
    :::2.txt
    

      

      

    草都可以从石头缝隙中长出来更可况你呢
  • 相关阅读:
    MyString
    Django疑难问题
    mysql 疑难问题-django
    python时间转换 ticks-FYI
    django建议入门-FYI
    Python风格规范-FYI
    scrum敏捷开发☞
    git基本命令
    centos下的安装mysql,jdk
    memcached for .net on windows
  • 原文地址:https://www.cnblogs.com/rdchenxi/p/11175310.html
Copyright © 2011-2022 走看看