更新时间:2025-08-15 GMT+08:00

ProxyCacheContent

表1 ProxyCacheContent

参数

是否必选

参数类型

描述

cache_key

PluginProxyCacheKey object

根据配置参数作为响应缓存键值,cache_key为必填项,因此三个参数system_params、parameters、headers至少有一个参数进行配置。

cache_http_status_and_ttl

Array of PluginProxyCacheHttpStatusTtl objects

可缓存的HTTP状态码以及对应的缓存时间。

client_cache_control

PluginProxyCacheClientCacheControl object

允许客户端通过Cache-Control头来影响缓存策略。

cacheable_headers

Array of strings

允许缓存的后端Headers, 默认只缓存Content-Type,Content-Encoding,Content-Language头。支持最多20个参数,参数长度为1~64个字符。无法添加API网关增加的系统响应头(x-apig-*,x-request-id等)。

表2 PluginProxyCacheKey

参数

是否必选

参数类型

描述

system_params

Array of strings

使用网关内置系统参数作为响应缓存键值。

网关内置参数取值及对应含义:

  • $context.sourceIp:API调用者的源地址
  • $context.stage:API调用的部署环境
  • $context.apiId:API的ID
  • $context.appId:API调用者的APP对象ID
  • $context.requestId:当次API调用生成请求ID
  • $context.serverAddr:网关的服务器地址
  • $context.serverName:网关的服务器名称
  • $context.handleTime:本次API调用的处理时间
  • $context.providerAppId:API拥有者的应用对象ID,暂不支持使用
  • $context.apiName:API的名称,需要发布API后才可使用此参数
  • $context.appName:调用API所使用的凭据名称

parameters

Array of strings

使用请求query参数作为响应缓存键值。

headers

Array of strings

使用请求头作为响应缓存键值。

表3 PluginProxyCacheHttpStatusTtl

参数

是否必选

参数类型

描述

http_status

Array of integers

根据HTTP响应码决定是否缓存。

ttl

Integer

缓存的超期时间,单位为s。

表4 PluginProxyCacheClientCacheControl

参数

是否必选

参数类型

描述

mode

String

客户端允许影响缓存策略的模式。支持的取值:

  • off: 拒绝所有端
  • all: 允许所有端
  • apps: 允许appId取值在datas列表中的端

datas

Array of strings

如果mode配置为app, 则允许AppId在以下列表中的取值。