CfnCachePolicyPropsMixin
- class aws_cdk.mixins_preview.aws_cloudfront.mixins.CfnCachePolicyPropsMixin(props, *, strategy=None)
Bases:
MixinA cache policy.
When it’s attached to a cache behavior, the cache policy determines the following:
The values that CloudFront includes in the cache key. These values can include HTTP headers, cookies, and URL query strings. CloudFront uses the cache key to find an object in its cache that it can return to the viewer.
The default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache.
The headers, cookies, and query strings that are included in the cache key are also included in requests that CloudFront sends to the origin. CloudFront sends a request when it can’t find a valid object in its cache that matches the request’s cache key. If you want to send values to the origin but not include them in the cache key, use
OriginRequestPolicy.- See:
- CloudformationResource:
AWS::CloudFront::CachePolicy
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_cloudfront import mixins as cloudfront_mixins cfn_cache_policy_props_mixin = cloudfront_mixins.CfnCachePolicyPropsMixin(cloudfront_mixins.CfnCachePolicyMixinProps( cache_policy_config=cloudfront_mixins.CfnCachePolicyPropsMixin.CachePolicyConfigProperty( comment="comment", default_ttl=123, max_ttl=123, min_ttl=123, name="name", parameters_in_cache_key_and_forwarded_to_origin=cloudfront_mixins.CfnCachePolicyPropsMixin.ParametersInCacheKeyAndForwardedToOriginProperty( cookies_config=cloudfront_mixins.CfnCachePolicyPropsMixin.CookiesConfigProperty( cookie_behavior="cookieBehavior", cookies=["cookies"] ), enable_accept_encoding_brotli=False, enable_accept_encoding_gzip=False, headers_config=cloudfront_mixins.CfnCachePolicyPropsMixin.HeadersConfigProperty( header_behavior="headerBehavior", headers=["headers"] ), query_strings_config=cloudfront_mixins.CfnCachePolicyPropsMixin.QueryStringsConfigProperty( query_string_behavior="queryStringBehavior", query_strings=["queryStrings"] ) ) ) ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::CloudFront::CachePolicy.- Parameters:
props (
Union[CfnCachePolicyMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['cachePolicyConfig']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental
CachePolicyConfigProperty
- class CfnCachePolicyPropsMixin.CachePolicyConfigProperty(*, comment=None, default_ttl=None, max_ttl=None, min_ttl=None, name=None, parameters_in_cache_key_and_forwarded_to_origin=None)
Bases:
objectA cache policy configuration.
This configuration determines the following:
The values that CloudFront includes in the cache key. These values can include HTTP headers, cookies, and URL query strings. CloudFront uses the cache key to find an object in its cache that it can return to the viewer.
The default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache.
If your minimum TTL is greater than 0, CloudFront will cache content for at least the duration specified in the cache policy’s minimum TTL, even if the
Cache-Control: no-cache,no-store, orprivatedirectives are present in the origin headers.The headers, cookies, and query strings that are included in the cache key are also included in requests that CloudFront sends to the origin. CloudFront sends a request when it can’t find a valid object in its cache that matches the request’s cache key. If you want to send values to the origin but not include them in the cache key, use
OriginRequestPolicy.- Parameters:
comment (
Optional[str]) – A comment to describe the cache policy. The comment cannot be longer than 128 characters.default_ttl (
Union[int,float,None]) – The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. CloudFront uses this value as the object’s time to live (TTL) only when the origin does not sendCache-ControlorExpiresheaders with the object. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide . The default value for this field is 86400 seconds (one day). If the value ofMinTTLis more than 86400 seconds, then the default value for this field is the same as the value ofMinTTL.max_ttl (
Union[int,float,None]) –The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. CloudFront uses this value only when the origin sends
Cache-ControlorExpiresheaders with the object. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide . The default value for this field is 31536000 seconds (one year). If the value ofMinTTLorDefaultTTLis more than 31536000 seconds, then the default value for this field is the same as the value ofDefaultTTL.min_ttl (
Union[int,float,None]) –The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
name (
Optional[str]) – A unique name to identify the cache policy.parameters_in_cache_key_and_forwarded_to_origin (
Union[IResolvable,ParametersInCacheKeyAndForwardedToOriginProperty,Dict[str,Any],None]) – The HTTP headers, cookies, and URL query strings to include in the cache key. The values included in the cache key are also included in requests that CloudFront sends to the origin.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_cloudfront import mixins as cloudfront_mixins cache_policy_config_property = cloudfront_mixins.CfnCachePolicyPropsMixin.CachePolicyConfigProperty( comment="comment", default_ttl=123, max_ttl=123, min_ttl=123, name="name", parameters_in_cache_key_and_forwarded_to_origin=cloudfront_mixins.CfnCachePolicyPropsMixin.ParametersInCacheKeyAndForwardedToOriginProperty( cookies_config=cloudfront_mixins.CfnCachePolicyPropsMixin.CookiesConfigProperty( cookie_behavior="cookieBehavior", cookies=["cookies"] ), enable_accept_encoding_brotli=False, enable_accept_encoding_gzip=False, headers_config=cloudfront_mixins.CfnCachePolicyPropsMixin.HeadersConfigProperty( header_behavior="headerBehavior", headers=["headers"] ), query_strings_config=cloudfront_mixins.CfnCachePolicyPropsMixin.QueryStringsConfigProperty( query_string_behavior="queryStringBehavior", query_strings=["queryStrings"] ) ) )
Attributes
- comment
A comment to describe the cache policy.
The comment cannot be longer than 128 characters.
- default_ttl
The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
CloudFront uses this value as the object’s time to live (TTL) only when the origin does not send
Cache-ControlorExpiresheaders with the object. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .The default value for this field is 86400 seconds (one day). If the value of
MinTTLis more than 86400 seconds, then the default value for this field is the same as the value ofMinTTL.
- max_ttl
The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
CloudFront uses this value only when the origin sends
Cache-ControlorExpiresheaders with the object. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .The default value for this field is 31536000 seconds (one year). If the value of
MinTTLorDefaultTTLis more than 31536000 seconds, then the default value for this field is the same as the value ofDefaultTTL.
- min_ttl
The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide .
- name
A unique name to identify the cache policy.
- parameters_in_cache_key_and_forwarded_to_origin
The HTTP headers, cookies, and URL query strings to include in the cache key.
The values included in the cache key are also included in requests that CloudFront sends to the origin.
HeadersConfigProperty
- class CfnCachePolicyPropsMixin.HeadersConfigProperty(*, header_behavior=None, headers=None)
Bases:
objectAn object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin.
- Parameters:
header_behavior (
Optional[str]) – Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin. Valid values are: -none– No HTTP headers are included in the cache key or in requests that CloudFront sends to the origin. Even when this field is set tonone, any headers that are listed in anOriginRequestPolicyare included in origin requests. -whitelist– Only the HTTP headers that are listed in theHeaderstype are included in the cache key and in requests that CloudFront sends to the origin.headers (
Optional[Sequence[str]]) – Contains a list of HTTP header names.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_cloudfront import mixins as cloudfront_mixins headers_config_property = cloudfront_mixins.CfnCachePolicyPropsMixin.HeadersConfigProperty( header_behavior="headerBehavior", headers=["headers"] )
Attributes
- header_behavior
Determines whether any HTTP headers are included in the cache key and in requests that CloudFront sends to the origin.
Valid values are:
none– No HTTP headers are included in the cache key or in requests that CloudFront sends to the origin. Even when this field is set tonone, any headers that are listed in anOriginRequestPolicyare included in origin requests.whitelist– Only the HTTP headers that are listed in theHeaderstype are included in the cache key and in requests that CloudFront sends to the origin.
- headers
Contains a list of HTTP header names.
ParametersInCacheKeyAndForwardedToOriginProperty
- class CfnCachePolicyPropsMixin.ParametersInCacheKeyAndForwardedToOriginProperty(*, cookies_config=None, enable_accept_encoding_brotli=None, enable_accept_encoding_gzip=None, headers_config=None, query_strings_config=None)
Bases:
objectThis object determines the values that CloudFront includes in the cache key.
These values can include HTTP headers, cookies, and URL query strings. CloudFront uses the cache key to find an object in its cache that it can return to the viewer.
The headers, cookies, and query strings that are included in the cache key are also included in requests that CloudFront sends to the origin. CloudFront sends a request when it can’t find an object in its cache that matches the request’s cache key. If you want to send values to the origin but not include them in the cache key, use
OriginRequestPolicy.- Parameters:
cookies_config (
Union[IResolvable,CookiesConfigProperty,Dict[str,Any],None]) – An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin.enable_accept_encoding_brotli (
Union[bool,IResolvable,None]) – A flag that can affect whether theAccept-EncodingHTTP header is included in the cache key and included in requests that CloudFront sends to the origin. This field is related to theEnableAcceptEncodingGzipfield. If one or both of these fields istrueand the viewer request includes theAccept-Encodingheader, then CloudFront does the following: - Normalizes the value of the viewer’sAccept-Encodingheader - Includes the normalized header in the cache key - Includes the normalized header in the request to the origin, if a request is necessary For more information, see Compression support in the Amazon CloudFront Developer Guide . If you set this value totrue, and this cache behavior also has an origin request policy attached, do not include theAccept-Encodingheader in the origin request policy. CloudFront always includes theAccept-Encodingheader in origin requests when the value of this field istrue, so including this header in an origin request policy has no effect. If both of these fields arefalse, then CloudFront treats theAccept-Encodingheader the same as any other HTTP header in the viewer request. By default, it’s not included in the cache key and it’s not included in origin requests. In this case, you can manually addAccept-Encodingto the headers whitelist like any other HTTP header.enable_accept_encoding_gzip (
Union[bool,IResolvable,None]) –A flag that can affect whether the
Accept-EncodingHTTP header is included in the cache key and included in requests that CloudFront sends to the origin. This field is related to theEnableAcceptEncodingBrotlifield. If one or both of these fields istrueand the viewer request includes theAccept-Encodingheader, then CloudFront does the following: - Normalizes the value of the viewer’sAccept-Encodingheader - Includes the normalized header in the cache key - Includes the normalized header in the request to the origin, if a request is necessary For more information, see Compression support in the Amazon CloudFront Developer Guide . If you set this value totrue, and this cache behavior also has an origin request policy attached, do not include theAccept-Encodingheader in the origin request policy. CloudFront always includes theAccept-Encodingheader in origin requests when the value of this field istrue, so including this header in an origin request policy has no effect. If both of these fields arefalse, then CloudFront treats theAccept-Encodingheader the same as any other HTTP header in the viewer request. By default, it’s not included in the cache key and it’s not included in origin requests. In this case, you can manually addAccept-Encodingto the headers whitelist like any other HTTP header.headers_config (
Union[IResolvable,HeadersConfigProperty,Dict[str,Any],None]) – An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin.query_strings_config (
Union[IResolvable,QueryStringsConfigProperty,Dict[str,Any],None]) – An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_cloudfront import mixins as cloudfront_mixins parameters_in_cache_key_and_forwarded_to_origin_property = cloudfront_mixins.CfnCachePolicyPropsMixin.ParametersInCacheKeyAndForwardedToOriginProperty( cookies_config=cloudfront_mixins.CfnCachePolicyPropsMixin.CookiesConfigProperty( cookie_behavior="cookieBehavior", cookies=["cookies"] ), enable_accept_encoding_brotli=False, enable_accept_encoding_gzip=False, headers_config=cloudfront_mixins.CfnCachePolicyPropsMixin.HeadersConfigProperty( header_behavior="headerBehavior", headers=["headers"] ), query_strings_config=cloudfront_mixins.CfnCachePolicyPropsMixin.QueryStringsConfigProperty( query_string_behavior="queryStringBehavior", query_strings=["queryStrings"] ) )
Attributes
- cookies_config
An object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and in requests that CloudFront sends to the origin.
- enable_accept_encoding_brotli
A flag that can affect whether the
Accept-EncodingHTTP header is included in the cache key and included in requests that CloudFront sends to the origin.This field is related to the
EnableAcceptEncodingGzipfield. If one or both of these fields istrueand the viewer request includes theAccept-Encodingheader, then CloudFront does the following:Normalizes the value of the viewer’s
Accept-EncodingheaderIncludes the normalized header in the cache key
Includes the normalized header in the request to the origin, if a request is necessary
For more information, see Compression support in the Amazon CloudFront Developer Guide .
If you set this value to
true, and this cache behavior also has an origin request policy attached, do not include theAccept-Encodingheader in the origin request policy. CloudFront always includes theAccept-Encodingheader in origin requests when the value of this field istrue, so including this header in an origin request policy has no effect.If both of these fields are
false, then CloudFront treats theAccept-Encodingheader the same as any other HTTP header in the viewer request. By default, it’s not included in the cache key and it’s not included in origin requests. In this case, you can manually addAccept-Encodingto the headers whitelist like any other HTTP header.
- enable_accept_encoding_gzip
A flag that can affect whether the
Accept-EncodingHTTP header is included in the cache key and included in requests that CloudFront sends to the origin.This field is related to the
EnableAcceptEncodingBrotlifield. If one or both of these fields istrueand the viewer request includes theAccept-Encodingheader, then CloudFront does the following:Normalizes the value of the viewer’s
Accept-EncodingheaderIncludes the normalized header in the cache key
Includes the normalized header in the request to the origin, if a request is necessary
For more information, see Compression support in the Amazon CloudFront Developer Guide .
If you set this value to
true, and this cache behavior also has an origin request policy attached, do not include theAccept-Encodingheader in the origin request policy. CloudFront always includes theAccept-Encodingheader in origin requests when the value of this field istrue, so including this header in an origin request policy has no effect.If both of these fields are
false, then CloudFront treats theAccept-Encodingheader the same as any other HTTP header in the viewer request. By default, it’s not included in the cache key and it’s not included in origin requests. In this case, you can manually addAccept-Encodingto the headers whitelist like any other HTTP header.
- headers_config
An object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and in requests that CloudFront sends to the origin.
- query_strings_config
An object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin.
QueryStringsConfigProperty
- class CfnCachePolicyPropsMixin.QueryStringsConfigProperty(*, query_string_behavior=None, query_strings=None)
Bases:
objectAn object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and in requests that CloudFront sends to the origin.
- Parameters:
query_string_behavior (
Optional[str]) – Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin. Valid values are: -none– No query strings in viewer requests are included in the cache key or in requests that CloudFront sends to the origin. Even when this field is set tonone, any query strings that are listed in anOriginRequestPolicyare included in origin requests. -whitelist– Only the query strings in viewer requests that are listed in theQueryStringNamestype are included in the cache key and in requests that CloudFront sends to the origin. -allExcept– All query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin, except those that are listed in theQueryStringNamestype, which are not included. -all– All query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin.query_strings (
Optional[Sequence[str]]) – Contains a list of query string names.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_cloudfront import mixins as cloudfront_mixins query_strings_config_property = cloudfront_mixins.CfnCachePolicyPropsMixin.QueryStringsConfigProperty( query_string_behavior="queryStringBehavior", query_strings=["queryStrings"] )
Attributes
- query_string_behavior
Determines whether any URL query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin.
Valid values are:
none– No query strings in viewer requests are included in the cache key or in requests that CloudFront sends to the origin. Even when this field is set tonone, any query strings that are listed in anOriginRequestPolicyare included in origin requests.whitelist– Only the query strings in viewer requests that are listed in theQueryStringNamestype are included in the cache key and in requests that CloudFront sends to the origin.allExcept– All query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin, except those that are listed in theQueryStringNamestype, which are not included.all– All query strings in viewer requests are included in the cache key and in requests that CloudFront sends to the origin.
- query_strings
Contains a list of query string names.