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.max_age(Duration.days(365)),
        s3deploy.CacheControl.immutable()
    ],
    prune=False
)

s3deploy.BucketDeployment(self, "HTMLBucketDeployment",
    sources=[s3deploy.Source.asset("./website", exclude=["*", "!index.html"])],
    destination_bucket=destination_bucket,
    cache_control=[
        s3deploy.CacheControl.max_age(Duration.seconds(0))
    ],
    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 immutable()

Sets ‘immutable’.

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 must_understand()

Sets ‘must-understand’.

Return type:

CacheControl

classmethod no_cache()

Sets ‘no-cache’.

Return type:

CacheControl

classmethod no_store()

Sets ‘no-store’.

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

classmethod stale_if_error(t)

Sets ‘stale-if-error=’.

Parameters:

t (Duration) –

Return type:

CacheControl

classmethod stale_while_revalidate(t)

Sets ‘stale-while-revalidate=’.

Parameters:

t (Duration) –

Return type:

CacheControl