2023-05-12 开启多语言插件支持……

nginx http-contact 合并CSS/JS 优化网站相应

nginx 苏 demo 2982℃

nginx-http-concat 是由淘宝开发的,用于合并静态资源使用的。

Nginx concat通过合并静态文件来减少http请求数来达到优化前端性能,可以在一定程度上能减少web服务器的压力。

 

下载地址:

wget https://codeload.github.com/alibaba/nginx-http-concat/zip/master

或者

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

 

编译第三方模块nginx-http-concat

./configure –with-http_stub_status_module –add-module=../nginx-http-concat-master/

make

查看nginx编译的参数

/usr/local/nginx/sbin/nginx -V

nginx conf调整

在location段里添加如下配置即可,

concat on;
concat_max_files 20;
concat_unique off;
concat_types text/css application/javascript;

重启ninx应用即可生效。

/usr/local/nginx/sbin/nginx -t

/usr/location/nginx/sbin/nginx -s reload

页面写法(示例)

<link rel=”stylesheet” href=”__TPL__/css/??ectouch_green.css,photoswipe.css,swiper.min.css,layer.css”/>

<script type=”text/javascript” src=”__TPL__/js/??jquery.min.js,layout.js”></script>

 

示例效果:

 

资料补充:

http1.1下浏览器的并发访问资源数

IE6                                 2
IE7                                 2
IE8                                 6
Firefox2                          2
Firefox3                          6
Safari 3,4                       4     
Chrome 1,2                    6     
Opera 9.63,10.00alpha    4 

 

 

 

打赏

转载请注明:苏demo的别样人生 » nginx http-contact 合并CSS/JS 优化网站相应

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)