# CacheCookieBehavior

Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin.

- Source: [`aws-cloudfront/lib/cache-policy.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts#L243)

## 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

- `behavior`: string — The behavior of cookies: allow all, none, an allow list, or a deny list.

- `cookies`: string[] — The cookies to allow or deny, if the behavior is an allow or deny list.

## Methods

- `all(): CacheCookieBehavior // chainable` (static) — 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` (static) — 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` (static) — 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` (static) — Cookies in viewer requests are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin.
