简介
ESI
一个实例配置
对所有请求都缓存5m
vcl 4.0;
backend default {
.host = "192.168.56.155";
.port = "80";
}
sub vcl_recv {
return (hash); # 进入缓存判断
}
sub vcl_backend_response {
set beresp.ttl = 5m; # 设置缓存的时间为5分钟,默认据说是2分钟
}
sub vcl_deliver {}
对不适用esi的请求缓存
{
name: "hello",
time: "<esi:include src=\"time\"/>"
}
设定/myweb/time
可以得到当前时间
vcl 4.0;
backend default {
.host = "192.168.56.155";
.port = "8080";
}
sub vcl_recv {
unset req.http.cookie;
if (req.url ~ "/myweb10/time") {
return(pass);
}
return (hash);
}
sub vcl_backend_response {
set beresp.do_esi = true; # 使用esi
set beresp.ttl = 1m;
}
sub vcl_deliver {}