CloudFront Distribution CacheBehavior
CacheBehavior is a property of the DistributionConfig property
that describes the Amazon CloudFront (CloudFront) cache behavior when the requested
URL matches a
pattern.
Syntax
JSON
{ "AllowedMethods" : [String, ...], "CachedMethods" : [String, ...], "Compress" :Boolean, "DefaultTTL" :Number, "FieldLevelEncryptionId" :String, "ForwardedValues" :ForwardedValues, "LambdaFunctionAssociations" : [ LambdaFunctionAssociation, ... ] "MaxTTL" :Number, "MinTTL" :Number, "PathPattern" :String, "SmoothStreaming" :Boolean, "TargetOriginId" :String, "TrustedSigners" : [String, ...], "ViewerProtocolPolicy" :String}
YAML
AllowedMethods: -StringCachedMethods: -StringCompress:BooleanDefaultTTL:NumberFieldLevelEncryptionId :String, ForwardedValues:ForwardedValuesLambdaFunctionAssociations: - LambdaFunctionAssociationMaxTTL:NumberMinTTL:NumberPathPattern:StringSmoothStreaming:BooleanTargetOriginId:StringTrustedSigners: -StringViewerProtocolPolicy:String
Properties
Note
For more information about the constraints and valid values of each property, see the CacheBehavior data type in the Amazon CloudFront API Reference.
AllowedMethods-
HTTP methods that CloudFront processes and forwards to your Amazon S3 bucket or your custom origin. You can specify
["HEAD", "GET"],["GET", "HEAD", "OPTIONS"], or["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]. If you don't specify a value, AWS CloudFormation specifies["HEAD", "GET"].Required: No
Type: List of String values
CachedMethods-
HTTP methods for which CloudFront caches responses. You can specify
["HEAD", "GET"]or["GET", "HEAD", "OPTIONS"]. If you don't specify a value, AWS CloudFormation specifies["HEAD", "GET"].Required: No
Type: List of String values
Compress-
Indicates whether CloudFront automatically compresses certain files for this cache behavior. For more information, see Serving Compressed Files in the Amazon CloudFront Developer Guide.
Required: No
Type: Boolean
DefaultTTL-
The default time in seconds that objects stay in CloudFront caches before CloudFront forwards another request to your custom origin to determine whether the object has been updated. This value applies only when your custom origin does not add HTTP headers, such as
Cache-Control max-age,Cache-Control s-maxage, andExpiresto objects.By default, AWS CloudFormation specifies
86400seconds (one day). If the value of theMinTTLproperty is greater than the default value, CloudFront uses the minimum Time to Live (TTL) value.Required: No
Type: Number
FieldLevelEncryptionId-
The value of ID for the field-level encryption configuration that you want CloudFront to use for encrypting specific fields of data for a cache behavior in your distribution. The default is an empty string.
Required: No
Type: String
ForwardedValues-
Specifies how CloudFront handles query strings or cookies.
Required: Yes
Type: ForwardedValues type
LambdaFunctionAssociations-
Lambda function associations for the Amazon CloudFront distribution.
Required: No
Type: List of LambdaFunctionAssociation
Update requires: No interruption
MaxTTL-
The maximum time in seconds that objects stay in CloudFront caches before CloudFront forwards another request to your custom origin to determine whether the object has been updated. This value applies only when your custom origin does not add HTTP headers, such as
Cache-Control max-age,Cache-Control s-maxage, andExpiresto objects.By default, AWS CloudFormation specifies
31536000seconds (one year). If the value of theMinTTLorDefaultTTLproperty is greater than the maximum value, CloudFront uses the default TTL value.Required: No
Type: Number
MinTTL-
The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin to see whether the object has been updated.
Required: No
Type: Number
PathPattern-
The pattern to which this cache behavior applies. For example, you can specify
images/*.jpg.When CloudFront receives an end-user request, CloudFront compares the requested path with path patterns in the order in which cache behaviors are listed in the template.
Required: Yes
Type: String
SmoothStreaming-
Indicates whether to use the origin that is associated with this cache behavior to distribute media files in the Microsoft Smooth Streaming format. If you specify
true, you can still use this cache behavior to distribute other content if the content matches thePathPatternvalue.Required: No
Type: Boolean
TargetOriginId-
The ID value of the origin to which you want CloudFront to route requests when a request matches the value of the
PathPatternproperty.Required: Yes
Type: String
TrustedSigners-
A list of AWS accounts that can create signed URLs in order to access private content.
Required: No
Type: List of String values
ViewerProtocolPolicy-
The protocol that users can use to access the files in the origin that you specified in the
TargetOriginIdproperty when a request matches the value of thePathPatternproperty. For more information about the valid values, see theViewerProtocolPolicycontent for the CacheBehavior data type in the Amazon CloudFront API Reference.Required: Yes
Type: String
