[英]Google CDN not Caching images - NGINX issue or CDN setup?
Site running Google Cloud CDN - According to numerous test is not Caching webp images - potentially all images.运行 Google Cloud CDN 的站点 - 根据众多测试,不会缓存 webp 图像 - 可能是所有图像。
https://gtmetrix.com/reports/mydoginsurance.com.au/TpxI5hxs/ 19 resources not using CDN:https://gtmetrix.com/reports/mydoginsurance.com.au/TpxI5hxs/ 19 个资源不使用 CDN:
Initially I used the Cloud CDN configuration of " Cache Static Content ".最初我使用“缓存 Static 内容”的 Cloud CDN 配置。 But upgraded this to " Use origin settings based on cache-control headers " Current Cache Settings:
但将此升级为“使用基于缓存控制标头的原始设置”当前缓存设置:
I am still seeing images, particularly webp not being cached by CDN.我仍然看到图像,尤其是 Webp 没有被 CDN 缓存。 I have also updated the .htaccess file to increase the TTL for webp.
我还更新了 .htaccess 文件以增加 webp 的 TTL。
Htaccess images TTL Htaccess 图像 TTL
I "think" this may be due to nginx and what is a "static" image.我“认为”这可能是由于 nginx 以及什么是“静态”图像。
How can I get these images cached properly in cloud CDN?如何在云 CDN 中正确缓存这些图像?
UPDATE:更新:
The cache seems to exist, its just too short and I can't seem to extend it.缓存似乎存在,它太短了,我似乎无法扩展它。 the CDN says its only caching these images under a 50min cage policy, but I've set htaccess to 1 year.
CDN 说它只在 50 分钟的笼子政策下缓存这些图像,但我已将 htaccess 设置为 1 年。
That GTmetrix report is simply wrong. GTmetrix 的报告是完全错误的。 They apparently don't correctly detect use of Cloud CDN.
他们显然没有正确检测到 Cloud CDN 的使用。 I see cache hits from Cloud CDN for images such as /images/banner.webp.
我看到来自 Cloud CDN 的缓存命中,例如 /images/banner.webp。
There's information on troubleshooting cache misses at https://cloud.google.com/cdn/docs/troubleshooting-steps#responses-not-cached that you can use to double check. https://cloud.google.com/cdn/docs/troubleshooting-steps#responses-not-cached中提供了有关解决缓存未命中问题的信息,您可以使用这些信息进行仔细检查。
Just adding to elving 's answer - the report is wrong - your site is using CDN for images too.只是添加到elving的答案 - 报告是错误的 -您的网站也在使用 CDN 图像。
I've fallowed official documentation on troubleshooting GCP's CDN .我已经阅读了有关 GCP 的 CDN 故障排除的官方文档。
Just run curl -s -D - -o /dev/null https://mydoginsurance.com.au/images/banner.webp
and you should get:只需运行
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
and when I ran it again a few minutes later:几分钟后我再次运行它时:
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
Third last line is age: 223
which means that this reponse was served from cache created 223 seconds ago ;最后第三行是
age: 223
,这意味着这个响应是从 223 秒前创建的缓存中提供的;
The last response in this example includes an Age header.
此示例中的最后一个响应包括 Age header。 Cloud CDN adds an Age header to responses that it serves from cache.
Cloud CDN 将 Age header 添加到它从缓存中提供的响应中。 Here, the header indicates that the response was successfully served from cache by using a cache entry that was created two seconds ago.
此处,header 表示响应已通过使用两秒前创建的缓存条目从缓存中成功提供。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.