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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南