CacheCookieBehavior Class
Determines whether any cookies 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
The behavior of cookies: allow all, none, an allow list, or a deny list.
The cookies to allow or deny, if the behavior is an allow or deny list.
Methods
all(): CacheCookieBehavior // chainable@staticmethod def all() -> CacheCookieBehaviorpublic static CacheCookieBehavior all()public static CacheCookieBehavior All()func All() CacheCookieBehaviorstatic#All cookies in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
allowList(...cookies: string[]): CacheCookieBehavior // chainable@staticmethod def allow_list(cookies: str) -> CacheCookieBehaviorpublic static CacheCookieBehavior allowList(String cookies)public static CacheCookieBehavior AllowList(string cookies)func AllowList(Cookies *string) CacheCookieBehaviorstatic#Only the provided `cookies` are included in the cache key and automatically included in requests that CloudFront sends to the origin.
denyList(...cookies: string[]): CacheCookieBehavior // chainable@staticmethod def deny_list(cookies: str) -> CacheCookieBehaviorpublic static CacheCookieBehavior denyList(String cookies)public static CacheCookieBehavior DenyList(string cookies)func DenyList(Cookies *string) CacheCookieBehaviorstatic#All cookies except the provided `cookies` are included in the cache key and automatically included in requests that CloudFront sends to the origin.
none(): CacheCookieBehavior // chainable@staticmethod def none() -> CacheCookieBehaviorpublic static CacheCookieBehavior none()public static CacheCookieBehavior None()func None() CacheCookieBehaviorstatic#Cookies in viewer requests are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin.