Trying to set the cache behaviors for a path in our app, AWS docs only show examples of trailing wildcards (i.e. /images/*
, https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-cachebehavior.html#cfn-cloudfront-distribution-cachebehavior-pathpattern, and also https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesPathPattern).
However we use a path pattern that implements language variables before the rest of the path so like (/{language}/product/{productId}
).
Is it acceptable, in the cloud formation template to set the PathPattern with a wildcard in each variable spot?
I.e. /*/product/*
.
If not and I use /product/*
I believe only routes like https://website.com/product/{productId}
will be picked up by cloudfront to analyze and a route like https://website.com/en/product/{productId}
would be missed.
/*/product/*
is valid, and correct, for https://example.com/en/product/{productId}
.
Perhaps even more correct would be /??/product/*
since ?
matches exactly 1 character, while *
matches 0 or more.
/product/*
would not match the example given.
Remember also that CloudFront matches requests against path patterns in precedence order, so the "first match" (in precedence order) always wins -- there is not a concept of "best match" or ambuguous/non-deterministic path pattern matching.