如何通过Varnish缓存API调用?

时间:2015-08-29 13:48:26

标签: caching varnish

我的目标是通过Varnish缓存RESTful API调用。当我在阅读stackoverflow和其他资源时,Varnish无法缓存帖子请求。这正是我所经历的。因此我开始使用?id = 30然后我意识到那些因为问号而没有被缓存。

所以问题是,如何通过Varnish缓存API调用?

以下是对我的API的两个示例调用,由Oauth2保护,其中包含2个参数:

curl --insecure -s -k https://test-api/v1/test -d 'access_token=72f50e68a0aed7921c6cb058de8e7e6ed4ebd692&clid=585970' -D- -o/dev/null
HTTP/1.1 200 OK
Date: Sat, 29 Aug 2015 13:02:36 GMT
Server: Apache/2.2.31 (Unix) PHP/5.6.11
X-Powered-By: PHP/5.6.11
Vary: Accept-Encoding
Content-Length: 2121
Content-Type: application/json
X-Varnish: 6558010
Age: 0
Via: 1.1 varnish-v4
Accept-Ranges: bytes
Set-Cookie: SERVERID=S3; path=/

curl --insecure -s -k https://test-api/v1/test -d 'access_token=72f50e68a0aed7921c6cb058de8e7e6ed4ebd692&clid=585970' -D- -o/dev/null
HTTP/1.1 200 OK
Date: Sat, 29 Aug 2015 13:02:56 GMT
Server: Apache/2.2.31 (Unix) PHP/5.6.11
X-Powered-By: PHP/5.6.11
Vary: Accept-Encoding
Content-Length: 2121
Content-Type: application/json
X-Varnish: 12814168
Age: 0
Via: 1.1 varnish-v4
Accept-Ranges: bytes
Set-Cookie: SERVERID=S2; path=/

是否可以配置Varnish来缓存API调用? POST / GET我不介意。

0 个答案:

没有答案