我尝试配置清漆,以便它可以处理jsonp 我使用这个来源作为基本概念:https://gist.github.com/640331
我正在使用清漆3.0.2所以我结束了with this
向服务器发送请求后:
curl http://example.com/test?callback=test
我得到以下内容:
test(<esi:include src="http://example.com/test" />);
Insted of:
test({...cached-json...});
syslog输出:
The syslog outputs the following:
May 09 12:48:45 [varnishd] before if for: /JSONP-ESI-TEMPLATE
May 09 12:48:45 [varnishd] before if for: callback, url: example.com:6081
May 09 12:48:45 [varnishd] in if for: callback, url: example.com:6081
May 09 12:52:40 [varnishd] before if for: /JSONP-ESI-TEMPLATE
May 09 12:52:40 [varnishd] in if for: /JSONP-ESI-TEMPLATE
May 09 12:52:40 [varnishd] before if for: obj.status == 760
May 09 12:52:40 [varnishd] in if for: obj.status == 760
May 09 12:52:40 [varnishd] before if for: beresp.http.X-ESI
May 09 12:52:40 [varnishd] in if for: beresp.http.X-ESI
May 09 12:52:40 [varnishd] before if for: beresp.http.X-JSONP-Server
May 09 12:52:40 [varnishd] in if for: beresp.http.X-JSONP-Server
如何评估esi请求以获取json?
答案 0 :(得分:1)
得到了解决方案! Looks like this
如果您使用gzip作为json响应,请不要忘记为jsonp启用gzip:
if ( beresp.http.content-type ~ "application/javascript" ) {
set beresp.do_gzip = true;
}