aws-cdk-lib.aws_cloudfront.CacheQueryStringBehavior

class CacheQueryStringBehavior

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.CacheQueryStringBehavior
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#CacheQueryStringBehavior
Javasoftware.amazon.awscdk.services.cloudfront.CacheQueryStringBehavior
Pythonaws_cdk.aws_cloudfront.CacheQueryStringBehavior
TypeScript (source)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

NameTypeDescription
behaviorstringThe behavior of query strings -- allow all, none, only an allow list, or a deny list.
queryStrings?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

NameDescription
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 allowList(...queryStrings)Only the provided queryStrings are included in the cache key and automatically included in requests that CloudFront sends to the origin.
static denyList(...queryStrings)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

  • CacheQueryStringBehavior

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

  • CacheQueryStringBehavior

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

  • CacheQueryStringBehavior

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

  • CacheQueryStringBehavior

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.