Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFront ForwardedValues ambiguous documentation

I'm configuring my CloudFront using CloudFormation, and on the AWS documentation page for the ForwardedValues property, we can see the following statement:

If you specify true for QueryString and you don't specify any values for QueryStringCacheKeys, CloudFront forwards all query string parameters to the origin and caches based on all query string parameters.

The word in bold (caches) are causing some confusion, as the meaning of this sentence is completely dependent on caches being a verb or caches being a noun:

  • Verb: CloudFormation will cache the queryparameter
  • Noun: CloudFormation will forward the queryparameter to the cache, but it will not cache the queryparameters

If I don't specify the QueryStringCacheKeys, what is the behaviour of CloudFront?

like image 349
Titulum Avatar asked Oct 11 '25 13:10

Titulum


2 Answers

I fixed it by specifying CachePolicyId

as in https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html

    Type: "AWS::CloudFront::Distribution"
    Properties:
      DistributionConfig:
        DefaultCacheBehavior:
          # Name: Managed-CachingOptimized
          # need either this parameter or 'ForwardedValues'
          CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
like image 152
keypoint Avatar answered Oct 15 '25 16:10

keypoint


If you don't specify the QueryStringCacheKeys, but only this:

ForwardedValues:
  QueryString: true

CloudFront will Forward all, cache based on all, which means that the request will be cached based on url+querystring and that the querystring is forwarded to the underlying system.

You can read more on this in the AWS documentation here.


enter image description here

like image 31
Michel Radosavljevic Avatar answered Oct 15 '25 15:10

Michel Radosavljevic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!