To enable CloudFront to access a custom HTTP backend, such as an EC2 instance or an Application Load Balancer (ALB), follow these steps:


By configuring security groups and allowing access from CloudFront edge locations, connectivity between CloudFront and backend resources like EC2 instances or ALBs can be established effectively.
You can utilize Cache-Control headers to manage how your API responses are cached by CloudFront. Here’s how it works:
Cache-Control: max-age=3600 tells CloudFront to cache the response for 1 hour.private directive, which tells CloudFront not to cache the response. If the responses are the same for all users, you can use the public directive to allow caching.no-store directive.Vary header in your responses. CloudFront considers the headers listed in the Vary header when caching the response.Remember, the effectiveness of caching depends on the configuration of your CloudFront distribution and the nature of your content. It’s important to set appropriate cache control headers in your origin server to ensure that CloudFront caches and serves your content as expected. Also, keep in mind that while caching can significantly improve performance, it might also serve stale content if not properly managed.