Google Lighthouse错误加载webp图像

Bil*_*oon 7 nginx lighthouse webp

我正在尝试提高我在Google灯塔上的效果得分。建议使用下一代图像格式,包括webp,因此我使用Nginx config来实现服务webp代替图像,其中请求接受标头包括webp。

map $http_accept $webp_suffix {
  default   "";
  "~*webp"  ".webp";
}

server {
  root /www/;
  listen 80 default_server;
  index index.html;

  location ~* ^\/images\/ {
    expires max;
    add_header Vary Accept;
    try_files $uri$webp_suffix $uri =404;
  }

  location / {
    try_files $uri $uri/index.html =404;
  }

  error_page 404 /404.html;
}
Run Code Online (Sandbox Code Playgroud)

现在页面加载速度大大提高,并且webp方法运行良好,可以回退到不存在webp或浏览器不支持的原始图像。但是,灯塔报告显示了一个错误,因此无法确定我是否正确实施了所有内容。这个错误是什么意思?

灯塔的机会

mar*_*uiz 1

将您的灯塔更新到版本 2.4 及以上

在之前的版本中,webp 扩展未正确处理

https://github.com/GoogleChrome/lighthouse/issues/3364

如果这不起作用,您可能需要在Github上提交问题