aws-cdk-lib.aws_s3_deployment.CacheControl

class CacheControl

LanguageType name
.NETAmazon.CDK.AWS.S3.Deployment.CacheControl
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awss3deployment#CacheControl
Javasoftware.amazon.awscdk.services.s3.deployment.CacheControl
Pythonaws_cdk.aws_s3_deployment.CacheControl
TypeScript (source)aws-cdk-lib » aws_s3_deployment » CacheControl

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

See also: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#SysMetadata

Example

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

NameTypeDescription
valueanyThe raw cache control setting.

value

Type: any

The raw cache control setting.

Methods

NameDescription
static fromString(s)Constructs a custom cache control key from the literal value.
static immutable()Sets 'immutable'.
static maxAge(t)Sets 'max-age=<duration-in-seconds>'.
static mustRevalidate()Sets 'must-revalidate'.
static mustUnderstand()Sets 'must-understand'.
static noCache()Sets 'no-cache'.
static noStore()Sets 'no-store'.
static noTransform()Sets 'no-transform'.
static proxyRevalidate()Sets 'proxy-revalidate'.
static sMaxAge(t)Sets 's-maxage=<duration-in-seconds>'.
static setPrivate()Sets 'private'.
static setPublic()Sets 'public'.
static staleIfError(t)Sets 'stale-if-error=<duration-in-seconds>'.
static staleWhileRevalidate(t)Sets 'stale-while-revalidate=<duration-in-seconds>'.

static fromString(s)

public static fromString(s: string): CacheControl

Parameters

  • s string

Returns

  • CacheControl

Constructs a custom cache control key from the literal value.


static immutable()

public static immutable(): CacheControl

Returns

  • CacheControl

Sets 'immutable'.


static maxAge(t)

public static maxAge(t: Duration): CacheControl

Parameters

  • t Duration

Returns

  • CacheControl

Sets 'max-age=<duration-in-seconds>'.


static mustRevalidate()

public static mustRevalidate(): CacheControl

Returns

  • CacheControl

Sets 'must-revalidate'.


static mustUnderstand()

public static mustUnderstand(): CacheControl

Returns

  • CacheControl

Sets 'must-understand'.


static noCache()

public static noCache(): CacheControl

Returns

  • CacheControl

Sets 'no-cache'.


static noStore()

public static noStore(): CacheControl

Returns

  • CacheControl

Sets 'no-store'.


static noTransform()

public static noTransform(): CacheControl

Returns

  • CacheControl

Sets 'no-transform'.


static proxyRevalidate()

public static proxyRevalidate(): CacheControl

Returns

  • CacheControl

Sets 'proxy-revalidate'.


static sMaxAge(t)

public static sMaxAge(t: Duration): CacheControl

Parameters

  • t Duration

Returns

  • CacheControl

Sets 's-maxage=<duration-in-seconds>'.


static setPrivate()

public static setPrivate(): CacheControl

Returns

  • CacheControl

Sets 'private'.


static setPublic()

public static setPublic(): CacheControl

Returns

  • CacheControl

Sets 'public'.


static staleIfError(t)

public static staleIfError(t: Duration): CacheControl

Parameters

  • t Duration

Returns

  • CacheControl

Sets 'stale-if-error=<duration-in-seconds>'.


static staleWhileRevalidate(t)

public static staleWhileRevalidate(t: Duration): CacheControl

Parameters

  • t Duration

Returns

  • CacheControl

Sets 'stale-while-revalidate=<duration-in-seconds>'.