Google CDN 未缓存图像 - NGINX 问题或 CDN 设置?

Google CDN not Caching images - NGINX issue or CDN setup?

站点运行Google云CDN - 根据大量测试,未缓存 webp 图像 - 可能是所有图像。

https://gtmetrix.com/reports/mydoginsurance.com.au/TpxI5hxs/ 19 resources not using CDN:

最初我使用“缓存静态内容”的云CDN配置。 但是将其升级为“使用基于 cache-control headers 的原始设置” Current Cache Settings:

我仍然看到图像,尤其是 webp 未被 CDN 缓存。 我还更新了 .htaccess 文件以增加 webp 的 TTL。

Htaccess images TTL

我“认为”这可能是由于 nginx 和什么是“静态”图像。

如何在云 CDN 中正确缓存这些图像?

更新:

缓存似乎存在,只是太短了,我似乎无法扩展它。 CDN 说它只在 50 分钟笼策略下缓存这些图像,但我将 htaccess 设置为 1 年。

image cache is saying its only set to 50min

那个 GTmetrix 报告完全是错误的。他们显然没有正确检测到 Cloud CDN 的使用。我看到 Cloud CDN 对 /images/banner.webp.

等图像的缓存命中

https://cloud.google.com/cdn/docs/troubleshooting-steps#responses-not-cached 上有关于缓存未命中故障排除的信息,您可以用来仔细检查。

只是添加到 elving 的回答中 - 报告是错误的 - 你的网站也在使用 CDN 获取图像

我休假了 documentation on troubleshooting GCP's CDN.

只要 运行 curl -s -D - -o /dev/null https://mydoginsurance.com.au/images/banner.webp 你应该得到:

HTTP/2 200
server: nginx
date: Thu, 25 Feb 2021 12:26:01 GMT
content-type: image/webp
content-length: 130564
last-modified: Fri, 16 Oct 2020 10:12:50 GMT
etag: "5f897222-1fe04"
x-powered-by: PleskLin
accept-ranges: bytes
via: 1.1 google
cache-control: max-age=86400,public
alt-svc: clear

当我 运行 几分钟后再次出现时:

HTTP/2 200
server: nginx
date: Thu, 25 Feb 2021 12:26:01 GMT
content-type: image/webp
content-length: 130564
last-modified: Fri, 16 Oct 2020 10:12:50 GMT
etag: "5f897222-1fe04"
x-powered-by: PleskLin
accept-ranges: bytes
via: 1.1 google
age: 223
cache-control: max-age=86400,public
alt-svc: clear

倒数第三行是 age: 223,这意味着 此响应是从 223 秒前创建的缓存中提供的

The last response in this example includes an Age header. Cloud CDN adds an Age header to responses that it serves from cache. Here, the header indicates that the response was successfully served from cache by using a cache entry that was created two seconds ago.