class CacheHeaderBehavior
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CloudFront.CacheHeaderBehavior |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#CacheHeaderBehavior |
![]() | software.amazon.awscdk.services.cloudfront.CacheHeaderBehavior |
![]() | aws_cdk.aws_cloudfront.CacheHeaderBehavior |
![]() | aws-cdk-lib » aws_cloudfront » CacheHeaderBehavior |
Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin.
Example
// Creating a custom cache policy for a Distribution -- all parameters optional
declare const bucketOrigin: origins.S3Origin;
const myCachePolicy = new cloudfront.CachePolicy(this, 'myCachePolicy', {
cachePolicyName: 'MyPolicy',
comment: 'A default policy',
defaultTtl: Duration.days(2),
minTtl: Duration.minutes(1),
maxTtl: Duration.days(10),
cookieBehavior: cloudfront.CacheCookieBehavior.all(),
headerBehavior: cloudfront.CacheHeaderBehavior.allowList('X-CustomHeader'),
queryStringBehavior: cloudfront.CacheQueryStringBehavior.denyList('username'),
enableAcceptEncodingGzip: true,
enableAcceptEncodingBrotli: true,
});
new cloudfront.Distribution(this, 'myDistCustomPolicy', {
defaultBehavior: {
origin: bucketOrigin,
cachePolicy: myCachePolicy,
},
});
Properties
Name | Type | Description |
---|---|---|
behavior | string | If no headers will be passed, or an allow list of headers. |
headers? | string[] | The headers for the allow/deny list, if applicable. |
behavior
Type:
string
If no headers will be passed, or an allow list of headers.
headers?
Type:
string[]
(optional)
The headers for the allow/deny list, if applicable.
Methods
Name | Description |
---|---|
static allow | Listed headers are included in the cache key and are automatically included in requests that CloudFront sends to the origin. |
static none() | HTTP headers are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin. |
static allowList(...headers)
public static allowList(...headers: string[]): CacheHeaderBehavior
Parameters
- headers
string
Returns
Listed headers are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
static none()
public static none(): CacheHeaderBehavior
Returns
HTTP headers are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin.