# CacheControl

Used for HTTP cache-control header, which influences downstream caches.

- Source: [`aws-s3-deployment/lib/bucket-deployment.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts#L839)
- Type last changed: v2.81.0 · 25 May 2023

## Example

```ts
declare const destinationBucket: s3.Bucket;
new s3deploy.BucketDeployment(this, 'BucketDeployment', {
  sources: [s3deploy.Source.asset('./website', { exclude: ['index.html'] })],
  destinationBucket,
  cacheControl: [
    s3deploy.CacheControl.maxAge(Duration.days(365)),
    s3deploy.CacheControl.immutable(),
  ],
  prune: false,
});

new s3deploy.BucketDeployment(this, 'HTMLBucketDeployment', {
  sources: [s3deploy.Source.asset('./website', { exclude: ['*', '!index.html'] })],
  destinationBucket,
  cacheControl: [
    s3deploy.CacheControl.maxAge(Duration.seconds(0)),
  ],
  prune: false,
});
```

## Properties

- `value`: any — The raw cache control setting.

## Methods

- `fromString(s: string): CacheControl // chainable` (static) — Constructs a custom cache control key from the literal value.

- `immutable(): CacheControl // chainable` (static) — Sets 'immutable'.

- `maxAge(t: Duration): CacheControl // chainable` (static) — Sets 'max-age=<duration-in-seconds>'.

- `mustRevalidate(): CacheControl // chainable` (static) — Sets 'must-revalidate'.

- `mustUnderstand(): CacheControl // chainable` (static) — Sets 'must-understand'.

- `noCache(): CacheControl // chainable` (static) — Sets 'no-cache'.

- `noStore(): CacheControl // chainable` (static) — Sets 'no-store'.

- `noTransform(): CacheControl // chainable` (static) — Sets 'no-transform'.

- `proxyRevalidate(): CacheControl // chainable` (static) — Sets 'proxy-revalidate'.

- `setPrivate(): CacheControl // chainable` (static) — Sets 'private'.

- `setPublic(): CacheControl // chainable` (static) — Sets 'public'.

- `sMaxAge(t: Duration): CacheControl // chainable` (static) — Sets 's-maxage=<duration-in-seconds>'.

- `staleIfError(t: Duration): CacheControl // chainable` (static) — Sets 'stale-if-error=<duration-in-seconds>'.

- `staleWhileRevalidate(t: Duration): CacheControl // chainable` (static) — Sets 'stale-while-revalidate=<duration-in-seconds>'.
