我正在使用云形式,并启用了这样的缓存:
Type: AWS::ApiGateway::Stage
Properties:
CacheClusterEnabled: true
CacheClusterSize: 0.5
我的方法取自Swagger。这是我的招摇文件
/v1/myPath/{id}:
get:
tags:
- Books
operationId: getBook
parameters:
- name: id
in: path
description: The ID of the book to retrieve
type: integer
format: int32
required: true
- name: custom-header
in: header
type: string
responses:
'200':
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: arn:aws:apigateway:us-west-1:lambda:path...
passthroughBehavior: when_no_match
requestParameters:
integration.request.header.custom-header: method.request.header.custom-header
cacheKeyParameters:
- method.request.header.custom-header
如何在Swagger.yaml中为我的Get请求设置缓存TTL?我似乎找不到这个文档。
参考文档,
cachettlinseconds:整数
CacheTtlInSeconds
The time-to-live (TTL) period, in seconds, that specifies how long API Gateway caches responses.
Required: No
Type: Integer
参考:
http://docs.aws.amazon.com/awscloudformation/latest/userguide/aws-properties-apigateway-apigateway-deployment stageScription.html
希望它有帮助。
edit1:
http://docs.aws.amazon.com/awscloudformation/latest/userguide/aws-properties-apities-apitgateway-method-method-method-methodresponse.html#cfn-apigateway-apigateway-apigateway-method-method-method-method-method-method-sonse-metsponse-responseparameters
缓存控制文档:
https://developer.mozilla.org/en-us/docs/web/http/headers/cache-control
将标头添加到云形式的方法,
ResponseParameters
Response parameters that API Gateway sends to the client that called a method. Specify response parameters as key-value pairs (string-to-Boolean maps), with a destination as the key and a Boolean as the value. Specify the destination using the following pattern: method.response.header.name, where the name is a valid, unique header name. The Boolean specifies whether a parameter is required.
Required: No
Type: Mapping of key-value pairs