CloudFront | default cache key | wildcard domain

0

Hi, according to https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/understanding-the-cache-key.html the default cache key is the CF distribution name, but the example shows that it's the host header.

What is right?

I'm asking because I have wildcard domain (*.example.com) that resolves to the CF distribution (CNAME) and if the cache key is based on the host header it won't cache objects between different domains. (for example test.example.com and test2.example.com won't share cached objects)

Is there a way to overcome this? i.e. I want the cache key to include the URI and the actual CF distribution name, not the host header.

Thanks, Roi

Roi
已提问 2 年前478 查看次数
1 回答
1
已接受的回答

Hi There,

I understand that as per the document you have read [1] you analyzed that the default cache key is the CF distribution name, but the example shows that it's the host header.

I understand the confusion, but no, the Host header is not included in the cache key by default. For that, one must select Host under "Cache Based on Selected Request Headers". What the documentation you linked refers to is that the CloudFront default domain is included in the cache key, by default, but not any custom Alternate Domain Names you may have.

With that said, to answer your question, the scenario you provided will only result in two different cache keys if Host is whitelisted. Otherwise the cache key will be the same irrespective of the CNAME you use to access the content in CloudFront.

I hope you find this helpful

[1] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/understanding-the-cache-key.html

Please note that I personally value your feedback and would appreciate it if you accept and thumbs up this response if it satisfies your question

Mfanelo
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则