您的位置:首页 > 理论基础 > 计算机网络

三.组合多个CSS、JavaScript文件的访问请求变成一个请求(ngx_http_concat_module)

2014-10-14 15:58 316 查看
1.该模块类似于apache中的mod_concat模块,用于合并多个文件在一个响应报文中。

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

2.进入到/home/jihuan/tengine-2.0.3,执行

$ cd /home/jihuan/tengine-2.0.3

$ ./configure --prefix=/usr/local/tengine --with-http_concat_module

$ sudo make && make install

3.编辑配置文件,关于concat配置可以查看官方文档http://tengine.taobao.org/document_cn/http_concat_cn.html

$ vi /usr/local/tengine/conf/nginx.conf

location / {

concat on; #开启concat模块
concat_max_files 30; #最大能接受的文件数量
root /root/html;
index index.html index.htm index.php;

}

4.重启

$ /usr/local/tengine/sbin/nginx -s reload

5.使用(请求参数需要用两个问号'??')

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

6.语法说明

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

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

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

如果是-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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: