简体   繁体   中英

How to set an AWS CloudFront Caching policy that doesn't cache errors

I would like to implement caching for my image service for my application, so I am using a CloudFront caching policy. Each image has a uuid, so the TTL for the objects is very long. However, there is an edge case that on the initial upload, I will be making a request to get the image that will likely fail on the first attempt. I do not want to cache this error status because the request will be made again soon after, and this should be a successful request. However, my cache is storing the error, so subsequent requests do not succeed. Does anyone know a simple solution to not store errors in the cache?

A custom response can be created when a 404 is returned from your origin doing so allows you to override the TTL of the cached error response https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesErrorPages

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM