<?php
echo 'Hello, I will be cached';
?>
<esi:include src="/your-uncacheable.php"/>
显然,您会将生成不缓存的 HTML 的逻辑放入/your-uncacheable.php.
然后您将在 VCL 中启用 ESI:
sub vcl_backend_response {
if (bereq.url == "/location") {
set beresp.do_esi = true; // Do ESI processing
set beresp.ttl = 24 h; // Sets the TTL on the HTML above
} elseif (bereq.url == "/your-uncacheable.php") {
set beresp.ttl = 0m; // Sets zero TTL on
// the included object
}
}
是的,这是可能的。您在ESI 包含.
也就是说,您的
/location
代码必须重写以拆分可缓存/不可缓存的内容,例如:显然,您会将生成不缓存的 HTML 的逻辑放入
/your-uncacheable.php
.然后您将在 VCL 中启用 ESI: