当授权 header 出现在请求中时,它总是缓存未命中

When Authorization header is present in the request, its' always a Cache Miss

当入站请求中出现授权 header 时,它始终是缓存未命中。我的要求是,我需要 ATS 像对待任何其他 [=25] 一样对待 Authorization header =](它不应该导致缓存未命中,它应该被转发到上游服务)。我怎样才能做到这一点。

这听起来可能 non-secure,但是,我有一个特定的用例。此缓存供内部使用,其访问由其他方式控制。

我试过了

根据 official documentation

By default, Traffic Server does not cache objects with the following request headers:

Authorization

Cache-Control: no-store

Cache-Control: no-cache

To configure Traffic Server to ignore this request header,

Edit proxy.config.http.cache.ignore_client_no_cache in records.config.

CONFIG proxy.config.http.cache.ignore_client_no_cache INT 1 Run the command traffic_ctl config reload to apply the configuration changes.

但是,运气不好

如果您的来源 returns cache-control header 带有 'public' 指令(例如,“Cache-Control: max-age=60 ,public") 或包含 s-maxage 指令(例如,“Cache-Control: s-maxage=60”),ATS 应开始缓存 object。相关的 http RFC: https://www.rfc-editor.org/rfc/rfc2616#section-14.8

When a shared cache (see section 13.7) receives a request
  containing an Authorization field, it MUST NOT return the
  corresponding response as a reply to any other request, unless one
  of the following specific exceptions holds:
  1. If the response includes the "s-maxage" cache-control
     directive, the cache MAY use that response

... 3.如果响应包含“public”cache-control指令, 它可能会在回复任何后续请求时返回。

同样,您也可以使用 header_rewrite 插件从请求中删除授权 header,或添加 public/s-maxage.

实际上这个 https://docs.trafficserver.apache.org/en/latest/admin-guide/configuration/cache-basics.en.html#configuring-traffic-server-to-ignore-www-authenticate-headers 对我有用。

WWW-Authenticate Header 外,以下说明也适用于 Authorization header。他们需要更新文档。

将流量服务器配置为忽略 WWW-Authenticate Headers

默认情况下,Traffic Server 不缓存包含 WWW-Authenticate 响应 header 的 objects。 WWW-Authenticate header 包含客户端在准备对源服务器的身份验证质询响应时使用的身份验证参数。

当您将 Traffic Server 配置为忽略源服务器 WWW-Authenticate headers 时,所有 objects 和 WWW-Authenticate headers 都存储在缓存中以供未来的请求。但是,在大多数情况下,不使用 WWW-Authenticate header 缓存 objects 的默认行为是合适的。如果您了解 HTTP 1.1.

,则仅将 Traffic Server 配置为忽略服务器 WWW-Authenticate headers

将 Traffic Server 配置为忽略服务器 WWW-Authenticate headers:

records.config 中编辑 proxy.config.http.cache.ignore_authentication

CONFIG proxy.config.http.cache.ignore_authentication INT 1

运行 命令 traffic_ctl config reload 应用配置更改。