- Newest
- Most votes
- Most comments
Hello,
To resolve the caching conflict in your CloudFront distribution while using multiple subdomains with the same URL paths, you can take the following approachs by using Cache Key Customization :
You can customize the cache key in CloudFront to include the subdomain as part of the cache key. This way, CloudFront will cache assets separately for each subdomain.
-
Steps to Customize Cache Key: 1- Open the CloudFront Console: Go to the AWS Management Console and open the CloudFront service.
2- Select Your Distribution: Click on the distribution you want to modify.
3- Edit Cache Behavior: In the "Behaviors" tab, select the cache behavior you want to modify, then click "Edit".
4- Configure Cache Key Settings: Cache key and origin requests: Choose "Use a Cache Policy and Origin Request Policy". Cache Policy: Either create a new cache policy or modify an existing one. In the cache policy settings, ensure that you include the "Headers" option that specifies the Host header. This will differentiate cache entries based on the subdomain.
5- Save Changes: After making the changes, save your settings.
By following the above steps, you can effectively customize the cache key in CloudFront to differentiate between resources served from different subdomains. This approach helps maintain the integrity of your content and ensures that each subdomain serves the correct resources without conflicts.
I hope this help !
Regards,
I think you will need a separate CF distribution for each subdomain with its own custom domain and an origin pointing the corresponding EC2 instance.
Relevant content
asked 5 years ago
asked 4 years ago
asked 2 years ago

Thanks for your support, problem solved