1

看来我不能在 https 请求中将 Google Cloud CDN 与 GKE Ingress 一起使用,因为 Ingress 控制器添加了一个 Vary http 标头:x-forwarded-proto,CDN 不会缓存(请参阅https://cloud.google.com /cdn/docs/caching#non-cacheable_content)。我认为添加标头是正确的,因为它告诉提供内容的应用程序它被请求为 https。但我不确定为什么 CDN 不会缓存带有此标头的页面。

我错过了什么还是有解决方法?

当页面被请求为 http 并被缓存时的标头示例

 Age: 1713
Cache-Control: public, max-age=2000
Content-Encoding: gzip
Content-Length: 8503
Content-Type: text/html; charset=UTF-8
Date: Thu, 13 Aug 2020 20:56:23 GMT
Server: Apache/2.4.38 (Debian)
Vary: Accept-Encoding
Via: 1.1 google
X-Powered-By: PHP/7.4.9

当页面请求为 http且未缓存时的标头示例:

    alt-svc: clear
cache-control: public, max-age=2000
content-encoding: gzip
content-length: 8499
content-type: text/html; charset=UTF-8
date: Thu, 13 Aug 2020 21:25:37 GMT
server: Apache/2.4.38 (Debian)
status: 200
vary: X-Forwarded-Proto,Accept-Encoding
via: 1.1 google
x-powered-by: PHP/7.4.9

 

非常感谢,山姆

4

1 回答 1

0

正如您已经确认 Cloud CDN 不会因为这个标头而缓存它。这是意料之中的。

关于添加的标头,如果您想使用 Cloud CDN 缓存此内容,您需要查看添加它的原因并找到删除它的方法。我找到了几篇您可以查看的文章:

您必须根据您的部署找到一个解决方案来删除此标头。

于 2020-08-14T19:52:58.750 回答