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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン