- Newest
- Most votes
- Most comments
This turned out to be user error. I was viewing a response cached in the browser, and the response it cached was the first, at which point Miss from cloudfront
was correct. When I cleared the cache, the next response I got had the header x-cache: Hit from cloudfront
.
The reason that CloudFront is not caching the responses is likely because the responses are including a query string, and CloudFront is configured to treat query strings as unique resources. This means that CloudFront will not cache the responses with query strings.
To fix this, you will need to configure CloudFront to ignore query strings when caching the resources. You can do this by going to the CloudFront distribution settings in the AWS Management Console, and under the "Behaviors" tab, select the behavior associated with your assets and set "Forward Query Strings" to "yes" and "Query String Cache Keys" to "none". This will tell CloudFront to ignore the query strings when caching the resources and use the headers you specified.
Relevant content
- asked a month ago
- Accepted Answerasked a year ago
- asked 5 years ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago
No, the URLs do not contain query strings. But what do you mean that I can change this by altering the CloudFront distribution? Amplify creates the distribution itself, and I don't think I have any direct access to it, isn't that right? They certainly do not appear on my CloudFront dashboard.