Skip to content
v2.274.0

CacheQueryStringBehavior Class ​

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 ​

ts
// 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 ​

behaviorstringbehaviorstrbehaviorStringBehaviorstringBehavior*stringrequired#
The behavior of query strings -- allow all, none, only an allow list, or a deny list.
queryStringsstring[]query_stringstyping.List[str]queryStringsList<String>QueryStringsstring[]QueryStrings*[]*string#
The query strings to allow or deny, if the behavior is an allow or deny list.

Methods ​

all(): CacheQueryStringBehavior // chainable@staticmethod def all() -> CacheQueryStringBehaviorpublic static CacheQueryStringBehavior all()public static CacheQueryStringBehavior All()func All() CacheQueryStringBehaviorstatic#
All query strings in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
allowList(...queryStrings: string[]): CacheQueryStringBehavior // chainable@staticmethod def allow_list(query_strings: str) -> CacheQueryStringBehaviorpublic static CacheQueryStringBehavior allowList(String queryStrings)public static CacheQueryStringBehavior AllowList(string queryStrings)func AllowList(QueryStrings *string) CacheQueryStringBehaviorstatic#
Only the provided `queryStrings` are included in the cache key and automatically included in requests that CloudFront sends to the origin.
denyList(...queryStrings: string[]): CacheQueryStringBehavior // chainable@staticmethod def deny_list(query_strings: str) -> CacheQueryStringBehaviorpublic static CacheQueryStringBehavior denyList(String queryStrings)public static CacheQueryStringBehavior DenyList(string queryStrings)func DenyList(QueryStrings *string) CacheQueryStringBehaviorstatic#
All query strings except the provided `queryStrings` are included in the cache key and automatically included in requests that CloudFront sends to the origin.
none(): CacheQueryStringBehavior // chainable@staticmethod def none() -> CacheQueryStringBehaviorpublic static CacheQueryStringBehavior none()public static CacheQueryStringBehavior None()func None() CacheQueryStringBehaviorstatic#
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.