Search code examples
amazon-cloudfront

Cloudfront Invalidation for custom origin root


Anyone know how to invalidate the root document of a custom origin that use's friendly url's?

eg: example.com ?

What would be the correct Object Path to request via the AWS Create Invalidation dialog?

The documentation only refers to actual files eg: images/image1.jpg, and where it does mention folders there are never the root only images/ etc.


Solution

  • The leading slash is optional¹ in an invalidation request for anything other than the root, but for the root of the site, the path to invalidate should just be /.

    ¹ optional in the console only. When interacting with the API (including with aws-cli and the SDKs) the leading slash is required. It isn't clear why the console implicitly and invisibly adds a slash when one isn't supplied, but that's what is happenning. Best practice would be to always supply the /.