Cloudflare 不转发 ETag header?

Cloudflare not forwarding ETag header?

我有一个使用 Cloudflare 的站点(例如 http://example.com)。没什么特别的,没有奇怪的页面规则,没有奇怪的设置,免费计划。

当我转到 http://example.com 时,我收到 GET http://example.com 请求的响应:

Cache-Control:no-cache, must-revalidate
CF-RAY:2b8d0490837f2828-SJC
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Sun, 26 Jun 2016 01:52:05 GMT
Expires:0
Pragma:no-cache
Server:cloudflare-nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:Express

请注意,响应没有 ETag header,即使它已在我的源服务器上启用。

当我直接访问原始服务器时,例如GET http://01.23.456.789/,我得到这个响应:

Accept-Ranges:bytes
Cache-Control:no-cache, must-revalidate
Connection:keep-alive
Date:Sun, 26 Jun 2016 01:56:53 GMT
ETag:W/"4cf8-1558a5557a0"
Expires:0
Pragma:no-cache
X-Powered-By:Express

有谁知道为什么 Cloudflare 不转发 ETag header?如何让 Cloudflare 转发 ETag?默认情况下,Cloudflare 不会缓存 GET http://example.com 请求,因为它是一个 HTML 页面。

我与 Cloudflare 技术支持工程师交谈,他帮助解决了我的问题。对于将来可能遇到同样问题的任何人,以下是解决问题的方法:

我为有问题的 URL 启用了电子邮件混淆(即删除了它的 ETag header)。根据https://support.cloudflare.com/hc/en-us/articles/218505467-Does-CloudFlare-support-ETag-headers-

Email Obfuscation will need to be disabled, otherwise the ETag headers
will be removed from the response. Email Obfuscation modifies the code
significantly enough it cannot be considered semantically equivalent.

虽然禁用电子邮件混淆仍然没有解决它。结果我启用了一个可以修改 HTML 的应用程序,因此必须使 ETag 无效。最后,设置禁用安全性、禁用应用程序、禁用性能的页面规则 URL 成功了。

就我而言,我遇到了同样的情况。 禁用电子邮件混淆和自动 HTTPS 重写对我来说还不够,因为我已经在 Cloudflare Apps 上安装了 'A Better Browser' 应用程序 (https://www.cloudflare.com/apps/a-better-browser)。 卸载该应用程序后,Etag 出现。

禁用电子邮件混淆和自动 HTTPS 重写,如 Cloudflare support:

中所述

When using weak ETag headers, disable Email Obfuscation and Automatic HTTPS Rewrites to ensure Cloudflare doesn't remove the ETag headers set by your origin web server.