跳转到内容
搜索文档

HEAD 请求与 Set-Cookie 标头

最后更新 查看 MarkdownAgent 设置

本页描述 Cloudflare 缓存系统与以下内容的交互行为:

  • HEAD 请求
  • Set-Cookie 响应标头

HEAD 请求与 Cache 的交互

Cloudflare 将可缓存请求HEAD 请求转换为 GET 请求。

当您对可缓存资源发出 HEAD 请求且 Cloudflare 在边缘缓存中没有该资源时,会发生缓存未命中。Cloudflare 会向源站发送 GET 请求,缓存完整响应并仅返回响应标头。请确保源站服务器设置为处理 GET 请求,即使仅预期 HEAD 请求,以确保与此行为的兼容性。

对于不可缓存请求,始终保留 Set-Cookie。对于可缓存请求,有三种可能的行为:

  • 从源站返回 Set-Cookie 并使用默认缓存级别。如果未启用 origin cache control,Cloudflare 会移除 Set-Cookie 并缓存资源。如果启用了 origin cache control,Cloudflare 不会缓存资源并保留 Set-Cookie。返回 BYPASS 缓存状态。

  • 从源站返回 Set-Cookie,且缓存级别在 Page Rules 中设置为 Cache Everything,或在 Cache Rules 中设置为 Eligible for cache。在这种情况下,Cloudflare 保留 Set-Cookie 但不缓存资源。每次都会返回缓存 MISS

  • 从源站返回 Set-Cookie,缓存级别在 Page Rules 中设置为 Cache Everything,或在 Cache Rules 中设置为 Eligible for cache,且使用"Ignore cache-control header and use this TTL"或"Status code TTL"设置显式设置了 edge cache TTL。在这种情况下,Cloudflare 移除 Set-Cookie 并缓存资源。

这篇文档对您有帮助吗?