0

I'm afraid I am fairly new to varnish but I have a problem whch I cannot find a solution to anywhere (yet): Varnish is set up to cache GET requests. We have some requests which have so many parameters that we decided to pass them in the body of the request. This works fine when we bypass Varnish but when we go through Varnish (for caching), the request is passed on without the body, so the service behind Varnish fails.

I know we could use POST, but we want to GET data. I also know that Varnish CAN pass the request body on if we use pass mode but as far as I can see, requests made in pass mode aren't cached. I've already put a hash into the url so that when things work, we will actually get the correct data from cache (as far as the url goes the calls would otherwise all look to be the same).

The problem now is "just" how to rewrite vcl_fetch to pass on the request body to the webserver? Any hints and tips welcome!

Thanks in advance

Jon

4

2 回答 2

0

我不认为你可以,但是,即使你可以,这也是非常危险的:Varnish 不会将请求正文存储到缓存或哈希表中,因此它无法看到具有相同 URI 的 2 个请求和不同的身体。

我还没有听说过读取请求正文的 VCL 密钥,但是,如果它存在,您可以将它传递给 req.hash 以区分请求。

无论如何,请求正文只能与 POST 或 PUT 一起使用……并且不应缓存 POST/PUT 请求。

请求正文应该向服务器发送数据。缓存用于获取数据...

我不知道细节,但我认为你的过程中存在设计问题......

于 2011-12-01T18:15:04.300 回答
0

我不确定我的问题是否正确,但是如果您尝试以某种方式与请求正文进行交互,这对于 VCL 是不可能的。您没有任何 VCL 变量/子程序来执行此操作。

您可以在此处(或在 man vcl 中)找到 VCL 中可用的变量列表:

我同意 Gauthier 的观点,您的系统似乎存在设计问题。

'希望有帮助。

于 2011-12-29T13:12:54.257 回答