2
votes

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?

2
The meaning here is CloudFront forwards all query string parameters to the origin and caches responses based on all query string parameters. It's a verb.Michael - sqlbot

2 Answers

2
votes

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
1
votes

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