0

I'm running Varnish 3.0.2, Apache2, Pressflow. I am trying to get ESI up and working for the first time, and it does work, but only the first time the parent page is requested. After that it just pulls the parent page and the replaced content from the cache. The only thing I can think of is that the included content is being cached permanently, even though I am telling it to not cache the included file at all, here is the object for the included file being stored...

11 ObjProtocol  c HTTP/1.1
11 ObjResponse  c OK
11 ObjHeader    c Date: Wed, 18 Jul 2012 23:25:56 GMT
11 ObjHeader    c X-Powered-By: PHP/5.3.3-1ubuntu9.10
11 ObjHeader    c Last-Modified: Wed, 18 Jul 2012 23:25:56 +0000
11 ObjHeader    c Expires: Sun, 11 Mar 1984 12:00:00 GMT
11 ObjHeader    c Vary: Cookie,Accept-Encoding
11 ObjHeader    c ETag: "1342653956"
11 ObjHeader    c Content-Encoding: gzip
11 ObjHeader    c Content-Length: 656
11 ObjHeader    c Content-Type: text/html
11 ObjHeader    c Server: Apache/2.2.11
11 ObjHeader    c Cache-Control: no-store

I've spent a full day on this, searched, read every article I can find, tried a whole heap of config tweaking, both in the VCL and in the HTTP headers. I can't see anything I'm doing wrong.

This is a snippet from my VCL, trying to force it to not store in the cache

sub vcl_fetch {
  set beresp.do_esi = true;
  if (req.url ~ "^/esi_") {
    set beresp.http.Cache-Control = "no-store";
    set beresp.ttl = 0s;
  }
}

I would add that I am seeing nothing to inidicate errors in the varnishlog. I've tried using just the path, and host + path in the include src, but no difference. It simply won't ask the backend for fresh content. If you were looking at the logs for the second and subsequent requests, you wouldn't realise it was an ESI page.

4

1 回答 1

0

在 sub vcl_recv {} 中提供一些信息,告诉 varnish 不要在缓存中查找请求,并从后端服务器定义一个额外的 http 响应元素,该元素由 vcl 中的条件处理。例如“编译指示:无缓存”..

您可以使用 ~ "^/esi_" .. 在 vcl_recv 中扩展此条件。

sub vcl_recv(
  # ...
  # the rest goes here ..
  # ...
  if ((req.url ~ "^/esi_") && (req.http.pragma ~ "no-cache")) {
    return (pass);
  }
 # ...
}
于 2012-07-30T12:30:07.663 回答