CachePolicy
- class aws_cdk.aws_cloudfront.CachePolicy(scope, id, *, cache_policy_name=None, comment=None, cookie_behavior=None, default_ttl=None, enable_accept_encoding_brotli=None, enable_accept_encoding_gzip=None, header_behavior=None, max_ttl=None, min_ttl=None, query_string_behavior=None)
Bases:
Resource
A Cache Policy configuration.
- Link:
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
- Resource:
AWS::CloudFront::CachePolicy
- ExampleMetadata:
infused
Example:
# Using an existing cache policy for a Distribution # bucket_origin: origins.S3Origin cloudfront.Distribution(self, "myDistManagedPolicy", default_behavior=cloudfront.BehaviorOptions( origin=bucket_origin, cache_policy=cloudfront.CachePolicy.CACHING_OPTIMIZED ) )
- Parameters:
scope (
Construct
) –id (
str
) –cache_policy_name (
Optional
[str
]) – A unique name to identify the cache policy. The name must only include ‘-’, ‘_’, or alphanumeric characters. Default: - generated from theid
comment (
Optional
[str
]) – A comment to describe the cache policy. The comment cannot be longer than 128 characters. Default: - no commentcookie_behavior (
Optional
[CacheCookieBehavior
]) – Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Default: CacheCookieBehavior.none()default_ttl (
Optional
[Duration
]) – The default amount of time for objects to stay in the CloudFront cache. Only used when the origin does not send Cache-Control or Expires headers with the object. Default: - The greater of 1 day andminTtl
enable_accept_encoding_brotli (
Optional
[bool
]) – Whether to normalize and include theAccept-Encoding
header in the cache key when theAccept-Encoding
header is ‘br’. Default: falseenable_accept_encoding_gzip (
Optional
[bool
]) – Whether to normalize and include theAccept-Encoding
header in the cache key when theAccept-Encoding
header is ‘gzip’. Default: falseheader_behavior (
Optional
[CacheHeaderBehavior
]) – Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Default: CacheHeaderBehavior.none()max_ttl (
Optional
[Duration
]) – The maximum amount of time for objects to stay in the CloudFront cache. CloudFront uses this value only when the origin sends Cache-Control or Expires headers with the object. Default: - The greater of 1 year anddefaultTtl
min_ttl (
Optional
[Duration
]) – The minimum amount of time for objects to stay in the CloudFront cache. Default: Duration.seconds(0)query_string_behavior (
Optional
[CacheQueryStringBehavior
]) – Determines whether any query strings are included in the cache key and automatically included in requests that CloudFront sends to the origin. Default: CacheQueryStringBehavior.none()
Methods
- apply_removal_policy(policy)
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
RemovalPolicy
) –- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- AMPLIFY = <jsii._reference_map.InterfaceDynamicProxy object>
- CACHING_DISABLED = <jsii._reference_map.InterfaceDynamicProxy object>
- CACHING_OPTIMIZED = <jsii._reference_map.InterfaceDynamicProxy object>
- CACHING_OPTIMIZED_FOR_UNCOMPRESSED_OBJECTS = <jsii._reference_map.InterfaceDynamicProxy object>
- ELEMENTAL_MEDIA_PACKAGE = <jsii._reference_map.InterfaceDynamicProxy object>
- USE_ORIGIN_CACHE_CONTROL_HEADERS = <jsii._reference_map.InterfaceDynamicProxy object>
- USE_ORIGIN_CACHE_CONTROL_HEADERS_QUERY_STRINGS = <jsii._reference_map.InterfaceDynamicProxy object>
- cache_policy_id
The ID of the cache policy.
- env
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- node
The tree node.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_cache_policy_id(scope, id, cache_policy_id)
Imports a Cache Policy from its id.
- Parameters:
scope (
Construct
) –id (
str
) –cache_policy_id (
str
) –
- Return type:
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool