My idea is to use cloudfront to cache one entire site that is in EC2. But I am having a lot of trouble to do that. If I set the cloudfront option Forward Headers to none, the default index.html from apache is cached (probably because the CF is caching the LB URL). If I set Forward Headers to whitelist and add host in Whitelist Headers the site displays normally but I can see in the Response Header:
X-Amz-Cf-Id:Ij8TsEU2hPehG53Op6LX1zFDmZfYWBOVFn8el8ApicCQYdYEi69HsQ==
X-Cache:Miss from cloudfront
Here is the current scenario:
- Route 53 with A alias pointing to CloudFront (for my naked domain and www)
- CloudFront with Origin Domain Name = load balancer DNS name, also the cname are configured to naked domain and www
- Load Balancer with EC2
- EC2 with several sites (I just want use CF in one of them)
Could anyone help me how to configure it correctly?
Update 1 Just a quick observation, the site is in WordPress. But, I don't think that is necessary to use any cdn module (like W3 Total Cache) because I want that the entire site be cached.
X-Cache:Miss from cloudfront
is exactly what you should expect to see, the first time a resource is requested through Cloudfront. It means Cloudfront didn't have a cached copy of the page. Refresh, and you should start to see "hit" instead of "miss." Have you tried that? – Michael - sqlbot