这可能是由于CloudFront默认的缓存行为引起的。为了解决这个问题,可以通过在CloudFront分配的缓存行为中启用高级缓存控制头来防止对象缓存在边缘位置上,从而减少对源服务器的请求。以下是如何启用高级缓存控制头的代码示例:
{
"Comment": "Enable advanced cache control headers",
"Version": "2016-09-01",
"Rules": [
{
"Actions": {
"Allow": {}
},
"Conditions": {
"IpAddress": {"aws:SourceIp": ["0.0.0.0/0"]}
},
"Priority": 1,
"ViewerProtocolPolicy": "allow-all",
"MaxTTL": 31536000,
"MinTTL": 0,
"DefaultTTL": 86400,
"AllowedMethods": {
"Quantity": 3,
"Items": [
"GET",
"HEAD",
"OPTIONS"
],
"CachedMethods": {
"Quantity": 2,
"Items": [
"GET",
"HEAD"
]
}
},
"Compress": true,
"LambdaFunctionAssociations": {
"Quantity": 0
},
"TargetOriginId": "origin-domain",
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
}
}
]
}
上一篇:AmazonCloudFront是否对TLS握手收取egress费用?
下一篇:AmazonCloudFront无法存储缓存且总是在浏览器的网页头中获得“x-cache:Missfromcloudfront”。