`

Nginx-concat-Module 减轻http请求连接数

阅读更多

http://blog.zongzk.com/index/archives/742

 

Nginx_concat_module是淘宝( JoshuaZhu )开发的基于Nginx减少HTTP请求数量的扩展模块,主要是用于合并减少前段用户Request的HTTP请求的数量。

taobao.com
taobao.com使用 concat_module  进行css样式合并。
安装:
安装 nginx_concat_module 需要重新编译 nginx。可以从这里 checkout 最新的代码,
svn checkout http://code.taobao.org/svn/nginx_concat_module/trunk/  $NGINX_CONCAT_MODULE
然后下载适合你自己版本的 nginx 源码包,在 ./configure 中增加参数
–add-module=$NGINX_CONCAT_MODULE
      
cd /us/local/src
wget http://nginx.org/download/nginx-1.0.10.tar.gz
tar xzvf nginx-1.0.10.tar.gz
cd nginx-1.0.10/
./configure –user=www –group=www  –prefix=/usr/local/nginx –with-http_stub_status_module  –with-http_sub_module    –with-http_flv_module   –with-http_gzip_static_module   –add-module=../nginx_concat_module/  && make && make install
使用方法:
  1. location /temp/ {
  2.                  # 打开concat 功能
  3.                  # 默认关闭
  4.                  concat on;
  5.                  # 允许concat最大的文件数(http://www.zongzk.com/temp/??1.css,2.css,3.css…10.css) 默认最大设置十个文件。
  6.                  # (默认: 10)
  7.                  # concat_max_files 10;
  8.                  # 只允许相同类型的文件(例:http://www.zongzk.com/temp/??zzk.css,zongzk.js 默认情况下是不允许的)
  9.                  # 默认是开启的
  10.                  # concat_unique on;
  11.                  # 允许内容的类型
  12.                  # (default: application/x-javascript, text/css)
  13.                  # concat_types text/html;
  14.         }
  1. #for i in {1..100};do echo “$i” > ./”$i”.css ;done
使用浏览器或者curl 进行访问
http://www.zongzk.com/temp/??1.css,2.css,3.css…10.css
–>
Ps:
css/js 有顺序需求谨慎使用。
注意不要和rewrite 发生冲突。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics