nginx 的提升多个小文件访问的性能模块
阿里开源的第三方模块下载地址:https://github.com/alibaba/nginx-http-concat
下载模块
1 | git clone https: / / github.com / alibaba / nginx - http - concat.git |
编译进nginx里
1 2 3 4 5 | 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 / 把可执行文件复制指定目录,备份之前可执行文件 |
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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。 } } |
网页
1 2 3 4 5 6 | [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 |
测试
1 2 3 4 5 6 7 8 9 10 11 12 | [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 |
草都可以从石头缝隙中长出来更可况你呢
分类:
web
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏