Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloudfront): managed cache policies UseOriginCacheControlHeaders #30379

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ export class CachePolicy extends Resource implements ICachePolicy {
public static readonly CACHING_DISABLED = CachePolicy.fromManagedCachePolicy('4135ea2d-6df8-44a3-9df3-4b5a84be39ad');
/** Designed for use with an origin that is an AWS Elemental MediaPackage endpoint. */
public static readonly ELEMENTAL_MEDIA_PACKAGE = CachePolicy.fromManagedCachePolicy('08627262-05a9-4f76-9ded-b50ca2e3a84f');
/**
* Designed for use with an origin that returns Cache-Control HTTP response headers.
* Does not serve different content based on values present in the query string.
*/
public static readonly USE_ORIGIN_CACHE_CONTROL_HEADERS = CachePolicy.fromManagedCachePolicy('83da9c7e-98b4-4e11-a168-04f0df8e2c65');
/**
* Designed for use with an origin that returns Cache-Control HTTP response headers.
* Serves different content based on values present in the query string.
*/
public static readonly USE_ORIGIN_CACHE_CONTROL_HEADERS_QUERY_STRINGS = CachePolicy.fromManagedCachePolicy('4cc15a8a-d715-48a4-82b8-cc0b614638fe');

/** Imports a Cache Policy from its id. */
public static fromCachePolicyId(scope: Construct, id: string, cachePolicyId: string): ICachePolicy {
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,13 @@ describe('CachePolicy', () => {
});

test('managed policies are provided', () => {
expect(CachePolicy.AMPLIFY.cachePolicyId).toEqual('2e54312d-136d-493c-8eb9-b001f22f67d2');
expect(CachePolicy.CACHING_OPTIMIZED.cachePolicyId).toEqual('658327ea-f89d-4fab-a63d-7e88639e58f6');
expect(CachePolicy.CACHING_OPTIMIZED_FOR_UNCOMPRESSED_OBJECTS.cachePolicyId).toEqual('b2884449-e4de-46a7-ac36-70bc7f1ddd6d');
expect(CachePolicy.CACHING_DISABLED.cachePolicyId).toEqual('4135ea2d-6df8-44a3-9df3-4b5a84be39ad');
expect(CachePolicy.ELEMENTAL_MEDIA_PACKAGE.cachePolicyId).toEqual('08627262-05a9-4f76-9ded-b50ca2e3a84f');
expect(CachePolicy.USE_ORIGIN_CACHE_CONTROL_HEADERS.cachePolicyId).toEqual('83da9c7e-98b4-4e11-a168-04f0df8e2c65');
expect(CachePolicy.USE_ORIGIN_CACHE_CONTROL_HEADERS_QUERY_STRINGS.cachePolicyId).toEqual('4cc15a8a-d715-48a4-82b8-cc0b614638fe');
});

// CookieBehavior and QueryStringBehavior have identical behavior
Expand Down
Loading