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
posta 2 anni fa478 visualizzazioni
1 Risposta
1
Risposta accettata

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
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande