介绍
该插件提供了一种智能方式来将多个URL复合为一个URL,从而将原来的多个响应合并为一个单一的响应。这非常有用,比如说,将多个CSS或js文件合并为一个文件。
目前git中的最新源码已经将comboHandler的内容移到plugins/experimental/esi目录下面了。目前的最新版本是1.2.0
安装
在configure时指定
--enable-experimental-plugins
在build时会生成该库comboo_handler.so。注意该插件需要和ESI模块结合来build和installed,因为它们共享common code
配置
在plugin.config中依次给出下面的参数
1).trigger combo handler的path,默认是"admin/v1/combo"
2).用于认证签名signature verification的key名称,默认是disabled,验证还未实现
3).colon分隔的header列表,假如至少存在一个响应,也会被添加到combo response中
如果这些参数中任何一个写-,则表示将采用默认值,从而该插件的配置项将是
combo_handler.so - - -
像original combohandler一样, 该插件生成形如
http://localhost/<dir>/<file-path>
的url,这里<dir>默认是"Host" header,除非query parameter中的file path部分使用冒号指定:
http://combo.com/admin/v1/combo?filepath1&dir1:filepath2&filepath3
这会得到下面的3个网页
http://localhost/combo.com/filepath1
http://localhost/dir1/filepath2
http://localhost/combo.com/filepath3
上面的url需要在remap规则中指定要map到的content servers
配置示例
[plugin.config]
combo_handler.so admin/v1/combo
[remap.config]
map http://combo.com http://os.combo.com @plugin=combo_handler.so
map http://localhost/combo.com http://os.combo.com
map http://localhost/dir1 http://os1.combo.com
注意:
1.如果records.config中设置了pristine_host_hdr为1,请求combo源站的Host头将是localhost
2.combo类型的url的最大长度不得超过3000字节,所包含的子请求不得超过30个
"/file1&p=/path1/&file2&file3&p=&/file4&p=/dir:path2/&file5&file6"
会得到如下文件路径
/file1
/path1/file2
/path1/file3
/file4
/dir:path2/file5
/dir:path2/file6
参考文献
[1].https://docs.trafficserver.apache.org/en/latest/reference/plugins/combo_handler.en.html
[2]. 源码中的README文件,这个更详细更新