Mystic
Mystic

Reputation: 1020

Is CloudFront's path pattern wildcard operator * greedy?

In CloudFront, when I use the wildcard * operator, is going to consume as many characters as possible (greedy) or as few (non-greedy)?

In regular expressions there's a difference but I'm not sure about CloudFront.

Specifically if I have

*c_*a*

I realize that that will match the following filename:

ddddc_1111c_ab.png

but will it match on the d's or the 1's?

Upvotes: 5

Views: 12391

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179084

Greediness isn't a factor here, because the only question that must be answered is "does this pattern match the path?" If it matches, it matches; only if it doesn't match does evaluation continue down the list. It's an ordered "first match," not a "best match."

When CloudFront receives an end-user request, the requested path is compared with path patterns in the order in which cache behaviors are listed in the distribution. The first match determines which cache behavior is applied to that request.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesPathPattern (emphasis added)


Note also that when using the AWS console, the ordering of the cache behaviors -- which determines what "first match" means -- can be manually rearranged using the move up/move down buttons, then saving your changes and waiting for the status of the distribution to change from In Progress back to Deployed -- but after changing this, you may need to do a cache invalidation of * so that anything incorrectly cached (because the pattern matching was not configured as intended) will not continue to be cached and served.

Upvotes: 4

Related Questions