class CacheQueryStringBehavior
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CloudFront.CacheQueryStringBehavior |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#CacheQueryStringBehavior |
![]() | software.amazon.awscdk.services.cloudfront.CacheQueryStringBehavior |
![]() | aws_cdk.aws_cloudfront.CacheQueryStringBehavior |
![]() | aws-cdk-lib » aws_cloudfront » CacheQueryStringBehavior |
Determines whether any URL query strings in viewer requests 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 | The behavior of query strings -- allow all, none, only an allow list, or a deny list. |
query | string[] | The query strings to allow or deny, if the behavior is an allow or deny list. |
behavior
Type:
string
The behavior of query strings -- allow all, none, only an allow list, or a deny list.
queryStrings?
Type:
string[]
(optional)
The query strings to allow or deny, if the behavior is an allow or deny list.
Methods
Name | Description |
---|---|
static all() | All query strings in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin. |
static allow | Only the provided queryStrings are included in the cache key and automatically included in requests that CloudFront sends to the origin. |
static deny | All query strings except the provided queryStrings are included in the cache key and automatically included in requests that CloudFront sends to the origin. |
static none() | Query strings in viewer requests are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin. |
static all()
public static all(): CacheQueryStringBehavior
Returns
All query strings in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
static allowList(...queryStrings)
public static allowList(...queryStrings: string[]): CacheQueryStringBehavior
Parameters
- queryStrings
string
Returns
Only the provided queryStrings
are included in the cache key and automatically included in requests that CloudFront sends to the origin.
static denyList(...queryStrings)
public static denyList(...queryStrings: string[]): CacheQueryStringBehavior
Parameters
- queryStrings
string
Returns
All query strings except the provided queryStrings
are included in the cache key and automatically included in requests that CloudFront sends to the origin.
static none()
public static none(): CacheQueryStringBehavior
Returns
Query strings in viewer requests are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin.