Appearance
concat
合并请求
下载
https://codeload.github.com/alibaba/nginx-http-concat/tar.gz/refs/tags/1.2.2
解压
tar -xzvf nginx-http-concat-1.2.2.tar.gz
编译
cd /root/nginx-1.18.0 ./configure --prefix=/usr/local/nginx/ --add-module=/root/nginx-http-concat-1.2.2/ make systemctl stop nginx cp ./objs/nginx /usr/local/nginx/sbin/ systemctl start nginx /usr/local/nginx/sbin/nginx -V
配置
假设前端没有合并 css 为一个文件,那么需要发起两次请求。
html
<link rel="stylesheet" href="/css/bg.css">
<link rel="stylesheet" href="/css/font.css">可以通过下面的写法合并这两个 css
html
<link rel="stylesheet" href="??/css/bg.css,/css/font.css">nginx
server {
listen 80;
server_name 192.168.44.101;
location / {
concat on;
concat_max_files 10;
root html;
index index.html;
}
location ~*/(js|css) {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}