Use Cloudfront's new cache policy and origin request policy
See original GitHub issueRecently AWS added a new way to configure Cloudfront’s cache policy, instead of declaring min/max/default TTLs you can create policies (or use predefined ones).
With cache policies we can finally use gzip and brotli compression at the same time (based on accept-encoding header). Brotli is superior in terms of the compression rate, which in end gives us better pagespeed.
Describe the solution you’d like
For start it would be enough to support CachePolicyId
and OriginRequestPolicyId
as cloudfront inputs. When those parameters are declared, TTLs won’t be required anymore.
In the future cloudfront component could take care of creating predefined policies.
Additional context You can learn more about this in AWS reference:
- CachePolicyId: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-defaultcachebehavior.html#cfn-cloudfront-distribution-defaultcachebehavior-cachepolicyid
- OriginRequestPolicyId: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-defaultcachebehavior.html#cfn-cloudfront-distribution-defaultcachebehavior-originrequestpolicyid
And here’s the AWS brotli-support announcement: https://aws.amazon.com/about-aws/whats-new/2020/09/cloudfront-brotli-compression/
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:11 (4 by maintainers)
Top GitHub Comments
@otekdo you won’t need to take any extra steps. Brotli will be enabled by default 🙂
Yeah I’m working exactly on this. Should have something ready this week.
I think it would be easy to predefine new cache policies for some of the behaviours we’ve got as they’re fairly static. If ends up being too much effort I’ll go with a happy medium until we move over to cdk.