CacheControl

class aws_cdk.aws_s3_deployment.CacheControl(*args: Any, **kwargs)

Bases: object

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

See

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

ExampleMetadata

infused

Example:

# destination_bucket: s3.Bucket

s3deploy.BucketDeployment(self, "BucketDeployment",
    sources=[s3deploy.Source.asset("./website", exclude=["index.html"])],
    destination_bucket=destination_bucket,
    cache_control=[s3deploy.CacheControl.from_string("max-age=31536000,public,immutable")],
    prune=False
)

s3deploy.BucketDeployment(self, "HTMLBucketDeployment",
    sources=[s3deploy.Source.asset("./website", exclude=["*", "!index.html"])],
    destination_bucket=destination_bucket,
    cache_control=[s3deploy.CacheControl.from_string("max-age=0,no-cache,no-store,must-revalidate")],
    prune=False
)

Attributes

value

The raw cache control setting.

Static Methods

classmethod from_string(s)

Constructs a custom cache control key from the literal value.

Parameters

s (str) –

Return type

CacheControl

classmethod max_age(t)

Sets ‘max-age=’.

Parameters

t (Duration) –

Return type

CacheControl

classmethod must_revalidate()

Sets ‘must-revalidate’.

Return type

CacheControl

classmethod no_cache()

Sets ‘no-cache’.

Return type

CacheControl

classmethod no_transform()

Sets ‘no-transform’.

Return type

CacheControl

classmethod proxy_revalidate()

Sets ‘proxy-revalidate’.

Return type

CacheControl

classmethod s_max_age(t)

Sets ‘s-maxage=’.

Parameters

t (Duration) –

Return type

CacheControl

classmethod set_private()

Sets ‘private’.

Return type

CacheControl

classmethod set_public()

Sets ‘public’.

Return type

CacheControl