看来我不能在 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
非常感谢,山姆