How to configure Cloudfront's 'Cache Behavior->Path Pattern' to include query parameters?

12,251

The Path Pattern unfortunately does not include/support the query part of a URL (See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.2) - only the path part of it.

From http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesPathPattern :

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.

[Emphasis added]

Share:
12,251

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I've setup a cloudfront distribution that contains two S3 origins. I want to setup a cache behavior policy such that the query parameter determines which bucket the resource is fetched from. So far I've tried setting the path pattern to include the query parameter but haven't had luck getting it to work. Below, I've attached a picture of my cache behavior settings:

    Cache Behavior Settings

    When I create a signed url like the following, cdn.example.com/image?image-type=webp, the image is loaded from the second origin instead of the first. Does anyone know how to configure the cache behavior so this works?