Caching 使用Varnish&;在PageSpeed Insights中利用浏览器缓存;Nginx

Caching 使用Varnish&;在PageSpeed Insights中利用浏览器缓存;Nginx,caching,nginx,Caching,Nginx,有人知道如何使用Varnish Cache和Nginx从PageSpeed Insights中删除杠杆浏览器缓存消息吗 我已尝试添加位置~*。。。块到服务器块,但导致站点崩溃。我想我错过了一个清漆设置,但找不到它 提前谢谢 要覆盖这些头并将元素放入缓存2分钟,可以使用以下配置: sub vcl_fetch { if (beresp.ttl < 120s) { set beresp.ttl = 120s; # Set the clients TTL on this obj

有人知道如何使用Varnish Cache和Nginx从PageSpeed Insights中删除杠杆浏览器缓存消息吗

我已尝试添加位置~*。。。块到服务器块,但导致站点崩溃。我想我错过了一个清漆设置,但找不到它


提前谢谢

要覆盖这些头并将元素放入缓存2分钟,可以使用以下配置:

sub vcl_fetch {
  if (beresp.ttl < 120s) {
   set beresp.ttl = 120s;

   # Set the clients TTL on this object
   set beresp.http.Cache-Control = "max-age=120";
  }
}
子vcl\u获取{
如果(贝雷斯普ttl<120s){
设置beresp.ttl=120s;
#在此对象上设置客户端TTL
设置beresp.http.Cache-Control=“max age=120”;
}
}
或者,在清漆4.0中:

sub vcl_backend_response {
  if (beresp.ttl < 120s) {
    set beresp.ttl = 120s;
    unset beresp.http.Cache-Control;
    set beresp.http.Cache-Control = "max-age=120";
  }
}
子vcl\u后端\u响应{
如果(贝雷斯普ttl<120s){
设置beresp.ttl=120s;
取消设置beresp.http.Cache-Control;
设置beresp.http.Cache-Control=“max age=120”;
}
}