class CacheControl
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.S3.Deployment.CacheControl |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awss3deployment#CacheControl |
Java | software.amazon.awscdk.services.s3.deployment.CacheControl |
Python | aws_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
| Name | Type | Description |
|---|---|---|
| value | any | The raw cache control setting. |
value
Type:
any
The raw cache control setting.
Methods
| Name | Description |
|---|---|
| static from | Constructs a custom cache control key from the literal value. |
| static immutable() | Sets 'immutable'. |
| static max | Sets 'max-age=<duration-in-seconds>'. |
| static must | Sets 'must-revalidate'. |
| static must | Sets 'must-understand'. |
| static no | Sets 'no-cache'. |
| static no | Sets 'no-store'. |
| static no | Sets 'no-transform'. |
| static proxy | Sets 'proxy-revalidate'. |
| static s | Sets 's-maxage=<duration-in-seconds>'. |
| static set | Sets 'private'. |
| static set | Sets 'public'. |
| static stale | Sets 'stale-if-error=<duration-in-seconds>'. |
| static stale | Sets 'stale-while-revalidate=<duration-in-seconds>'. |
static fromString(s)
public static fromString(s: string): CacheControl
Parameters
- s
string
Returns
Constructs a custom cache control key from the literal value.
static immutable()
public static immutable(): CacheControl
Returns
Sets 'immutable'.
static maxAge(t)
public static maxAge(t: Duration): CacheControl
Parameters
- t
Duration
Returns
Sets 'max-age=<duration-in-seconds>'.
static mustRevalidate()
public static mustRevalidate(): CacheControl
Returns
Sets 'must-revalidate'.
static mustUnderstand()
public static mustUnderstand(): CacheControl
Returns
Sets 'must-understand'.
static noCache()
public static noCache(): CacheControl
Returns
Sets 'no-cache'.
static noStore()
public static noStore(): CacheControl
Returns
Sets 'no-store'.
static noTransform()
public static noTransform(): CacheControl
Returns
Sets 'no-transform'.
static proxyRevalidate()
public static proxyRevalidate(): CacheControl
Returns
Sets 'proxy-revalidate'.
static sMaxAge(t)
public static sMaxAge(t: Duration): CacheControl
Parameters
- t
Duration
Returns
Sets 's-maxage=<duration-in-seconds>'.
static setPrivate()
public static setPrivate(): CacheControl
Returns
Sets 'private'.
static setPublic()
public static setPublic(): CacheControl
Returns
Sets 'public'.
static staleIfError(t)
public static staleIfError(t: Duration): CacheControl
Parameters
- t
Duration
Returns
Sets 'stale-if-error=<duration-in-seconds>'.
static staleWhileRevalidate(t)
public static staleWhileRevalidate(t: Duration): CacheControl
Parameters
- t
Duration
Returns
Sets 'stale-while-revalidate=<duration-in-seconds>'.

.NET
Go
Java
Python
TypeScript (