1

我尝试配置清漆,以便它可以处理 jsonp。
我使用这个来源作为基本概念:https ://gist.github.com/640331

我正在使用 varnish 3.0.2 所以我最终得到了这个

向服务器发送请求后:

curl http://example.com/test?callback=test

我得到以下信息:

test(<esi:include src="http://example.com/test" />);

安装:

test({...cached-json...});

系统日志输出:

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?

4

1 回答 1

1

得到解决方案! 看起来像这样

如果您使用 gzip 处理 json 响应,请不要忘记为 jsonp 启用 gzip:

if ( beresp.http.content-type ~ "application/javascript" ) { 
  set beresp.do_gzip = true;
}
于 2012-06-23T00:07:02.767 回答