Tengine的concat模块

昨天网上体验了一下Tengine的concat模块,非常不错,通过减少http请求次数来加快页面载入速度

官方地址:http://tengine.taobao.org/document_cn/http_concat_cn.html

concat模块的安装

默认安装tengine的时候是不安装http_concat_module的,需要重新install一下,还是使用tengine的源代码。

  • 配置

    ./configure [--with-http_concat_module | --with-http_concat_module=shared]

    --with-http_concat_module选项,concat模块将被静态编译到tengine中

    --with-http_concat_module=shared,concat模块将被编译成动态文件,采用动态模块的方式添加到tengine中

  • 编译,安装

    make&&make install

例如,我的tengine源码在/usr/local/src/tengine里面,我原来安装的tengine在/usr/local/tengine里。那么编译过程就是

cd /usr/local/src/tengine

./configure –prefix=/usrl/local/tengine –with-http_concat_module

make && make install

 

然后重启nginx就行。

如果是-with-http_concat_module=shared的话,会在tengine的modules目录里生成一个.so文件,需要在nginx的nginx.conf配置文件里加入

dso{

    load ngx_http_push_module.so; #我原来的一个shared模块

    load 你的so文件;

}

关于tengine的dso动态加载的配置可以参考官方的文档http://tengine.taobao.org/document_cn/dso_cn.html

或者前面的一个示例:nginx(Tengine)使用——新模块添加使用

 

然后就是添加配置

在nginx的server选项里的location里,填上concat on;

例如:

location / { 
    concat on; #开启concat模块
    root   /data/wwwroot/atc/public/; 
    index  index.html index.htm index.php; 
} 

然后给nginx重新reload一下就行 nginx –s reload

最后是开始使用

请求参数需要用两个问号('??')来激活concat特性,多个文件之间用逗号(,)连接

<script type="text/javascript" src="??js/jquery.js,js/slide_original.js,count/count/count.js"></script>

这样,便可以将jquery.js 和 slide_original.js 以及 count.js三个js文件的请求合并为一个了。

 

最后再推荐一下阿里的alibench.com,进行网站的即使探测。

淘宝开源的东西都非常给力~

posted @ 2013-01-13 16:05  浮云比翼  阅读(2740)  评论(0编辑  收藏  举报