By using AWS re:Post, you agree to the Terms of Use

Avoid resetting Cloudfront cache policy on Amplify deployment

0

I have a NextJS application with continuous deploys set up on Amplify. This application requires forwarding the Host header to the origin, so I use the "Amplify" managed cache policy as the Cloudfront's distribution default behaviour.

This cache policy is reset to legacy cache settings on each deploy. Is there a way to persist the cache policy between deployments? Or to always forward the Host header to the origin?

1 Answers
0

If you require that the host header be sent to the origin, but don't care if it is included in the cache key, then you can use the AllViewer origin request policy in your CloudFront distribution. That will ensure that all headers, cookies, and query strings are forwarded to the origin, regardless of the settings in the cache policy.

The issue with the cache policy being reset is interesting, and that should not be happening. I would reach out to support, as they should be able to investigate why that is happening.

profile picture
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions