AWS提供了可自定义缓存操作行为的CloudFront服务。用户可以在随后的请求中指定缓存时长和缓存标识等设置,以满足自己的需求。以下是一个包含代码示例的
"CacheBehaviors": [{
"PathPattern": "/images/*", // 匹配路径模式
"TargetOriginId": "my-bucket", // 目标服务ID
"ForwardedValues": {
"QueryString": false, // 传递查询串
"Cookies": {
"Forward": "none" // 不传递Cookie
}
},
"TrustedSigners": {
"Enabled": false, // 开启签名检查
"Quantity": 0,
"Items": []
},
"ViewerProtocolPolicy": "allow-all", // 客户端协议策略
"MinTTL": 0, // 最低过期时间
"MaxTTL": 31536000, // 最大过期时间
"DefaultTTL": 86400, // 默认过期时间
"AllowedMethods": {
"Quantity": 2,
"Items": ["GET", "HEAD"], // 允许的HTTP方法
"CachedMethods": {
"Quantity": 2,
"Items": ["GET", "HEAD"] // 缓存的HTTP方法
}
},
"SmoothStreaming": false, // 流式媒体
"Compress": false, // 压缩
"LambdaFunctionAssociations": {
"Quantity": 0,
"Items": []
}
}]