It seems I can't use Google Cloud CDN with GKE Ingress in https requests, because the Ingress controller adds a Vary http header: x-forwarded-proto, which CDN won't cache (see https://cloud.google.com/cdn/docs/caching#non-cacheable_content). I think it's correct that the header is added, because it tells the application serving the content that it's being requested as https. But I'm not sure why CDN won't cache pages with this header.
Am I missing something or is there a workaround?
Example of header when page is requested as http and is cached:
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
Example of header when page is requested as http and isn't cached:
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
Many thanks, Sam