CachePolicy
Source:
src/AWS/CloudFront/CachePolicy.ts
A CloudFront cache policy.
Cache policies determine the values CloudFront includes in the cache key, the headers, cookies and query strings it forwards to the origin, and the TTL bounds for cached responses. Policies are referenced by ID on a Distribution’s default behavior or per-path cache behaviors.
For AWS-managed policies (CachingOptimized, CachingDisabled, AllViewerExceptHostHeader) reference them by ID via the constants in {@link ManagedPolicies} instead of creating a custom policy.
Creating Cache Policies
Section titled “Creating Cache Policies”const cachePolicy = yield* CachePolicy("ApiCachePolicy", { comment: "Cache GETs by query string + Authorization", minTTL: 0, defaultTTL: 60, maxTTL: 3600, parametersInCacheKeyAndForwardedToOrigin: { EnableAcceptEncodingGzip: true, EnableAcceptEncodingBrotli: true, HeadersConfig: { HeaderBehavior: "whitelist", Headers: { Quantity: 1, Items: ["Authorization"] }, }, CookiesConfig: { CookieBehavior: "none" }, QueryStringsConfig: { QueryStringBehavior: "all" }, },});