Google Cloud CDN的缓存命中率为0%

时间:2018-07-06 01:24:45

标签: google-cloud-platform cdn google-cloud-cdn

我是CDN的新手,两天前,我将我的Wordpress网站移到了Google Cloud Platform GCE。我已经有一个启用CDN的负载均衡器,但是“缓存命中率”为0%,并且没有移动。

我的网站是https://cryptstorm.com

我使用此工具https://www.giftofspeed.com/cache-checker/进行了检查,似乎缓存控制和ETag正常运行,但CDN似乎未运行。 我也在这里https://www.cdnplanet.com/tools/cdnfinder/#site:https://cryptstorm.com 并且大多数请求都是直接向网站发出的。

我做错了什么,如何使CDN正常​​工作?

1 个答案:

答案 0 :(得分:2)

运行命令“ $ curl -sSL -D-https://cryptstorm.com -o / dev / null”后,将显示以下标头输出:

> HTTP/2 200 date: Tue, 10 Jul 2018 07:46:15 GMT content-type:
> text/html; charset=UTF-8 set-cookie:
> __cfduid=db3de46de5278430e9a9c1ba1d14f642b1531208774; expires=Wed, 10-Jul-19 07:46:14 GMT; path=/; domain=.cryptstorm.com ; HttpOnly;
> Secure x-powered-by: PHP/7.0.30 x-cf-powered-by: WP Rocket 3.0.5 link:
> <https://cryptstorm.com/wp-json/>; rel="https://api.w.org/"
> x-frame-options: SAMEORIGIN x-mod-pagespeed: 1.9.32.14-0 vary:
> Accept-Encoding cache-control: max-age=0, no-cache via: 1.1 google
> alt-svc: clear expect-ct: max-age=604800,
> report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
> server: cloudflare cf-ray: 43816a5b1986a857-CDG

我们可以专注于这一行:

“缓存控制:max-age = 0,无缓存”

这是因为未为网页https://cryptstorm.com设置缓存,即使最长使用期限为0秒。尝试对此进行修改,然后再次检查。

documentation中,我们可以阅读以下内容:

“如果满足以下任一条件,则不会缓存响应:

·它具有一个Cache-Control:无存储,无缓存或专用指令。”

如果仍然不能解决问题,我建议您使用Google Cloud Support开箱,因为他们将详细了解VPC中CDN的配置方式以及可能配置错误的内容。