class CacheControl
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.S3.Deployment.CacheControl |
Java | software.amazon.awscdk.services.s3.deployment.CacheControl |
Python | aws_cdk.aws_s3_deployment.CacheControl |
TypeScript (source) | @aws-cdk/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.fromString('max-age=31536000,public,immutable')],
prune: false,
});
new s3deploy.BucketDeployment(this, 'HTMLBucketDeployment', {
sources: [s3deploy.Source.asset('./website', { exclude: ['*', '!index.html'] })],
destinationBucket,
cacheControl: [s3deploy.CacheControl.fromString('max-age=0,no-cache,no-store,must-revalidate')],
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 max | Sets 'max-age=<duration-in-seconds>'. |
static must | Sets 'must-revalidate'. |
static no | Sets 'no-cache'. |
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'. |
String(s)
static frompublic static fromString(s: string): CacheControl
Parameters
- s
string
Returns
Constructs a custom cache control key from the literal value.
Age(t)
static maxpublic static maxAge(t: Duration): CacheControl
Parameters
- t
Duration
Returns
Sets 'max-age=<duration-in-seconds>'.
Revalidate()
static mustpublic static mustRevalidate(): CacheControl
Returns
Sets 'must-revalidate'.
Cache()
static nopublic static noCache(): CacheControl
Returns
Sets 'no-cache'.
Transform()
static nopublic static noTransform(): CacheControl
Returns
Sets 'no-transform'.
Revalidate()
static proxypublic static proxyRevalidate(): CacheControl
Returns
Sets 'proxy-revalidate'.
MaxAge(t)
static spublic static sMaxAge(t: Duration): CacheControl
Parameters
- t
Duration
Returns
Sets 's-maxage=<duration-in-seconds>'.
Private()
static setpublic static setPrivate(): CacheControl
Returns
Sets 'private'.
Public()
static setpublic static setPublic(): CacheControl
Returns
Sets 'public'.