I’m currently using AWS CloudFront to distribute requests to an Application Load Balancer (ALB), which then forwards them to EC2 instances. I need to configure caching based on the Host header value. Specifically:
If the Host header is api.domain.com, I don’t want CloudFront to cache the response at all.
If the Host header is web.domain.com, I want CloudFront to cache the response for 24 hours.
I understand that I need to use cache behaviors and cache policies, but I’m not sure how to set them up correctly to achieve the desired caching behavior based on the Host header value.
Do i need to modify cache-control headers using CloudFront-function/lambda-edge-function if so how to do so.