Interface ICachePolicyProps
Properties for creating a Cache Policy.
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface ICachePolicyProps
Syntax (vb)
Public Interface ICachePolicyProps
Remarks
ExampleMetadata: infused
Examples
// Creating a custom cache policy for a Distribution -- all parameters optional
S3Origin bucketOrigin;
var myCachePolicy = new CachePolicy(this, "myCachePolicy", new CachePolicyProps {
CachePolicyName = "MyPolicy",
Comment = "A default policy",
DefaultTtl = Duration.Days(2),
MinTtl = Duration.Minutes(1),
MaxTtl = Duration.Days(10),
CookieBehavior = CacheCookieBehavior.All(),
HeaderBehavior = CacheHeaderBehavior.AllowList("X-CustomHeader"),
QueryStringBehavior = CacheQueryStringBehavior.DenyList("username"),
EnableAcceptEncodingGzip = true,
EnableAcceptEncodingBrotli = true
});
new Distribution(this, "myDistCustomPolicy", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = bucketOrigin,
CachePolicy = myCachePolicy
}
});
Synopsis
Properties
CachePolicyName | A unique name to identify the cache policy. |
Comment | A comment to describe the cache policy. |
CookieBehavior | Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. |
DefaultTtl | The default amount of time for objects to stay in the CloudFront cache. |
EnableAcceptEncodingBrotli | Whether to normalize and include the |
EnableAcceptEncodingGzip | Whether to normalize and include the |
HeaderBehavior | Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. |
MaxTtl | The maximum amount of time for objects to stay in the CloudFront cache. |
MinTtl | The minimum amount of time for objects to stay in the CloudFront cache. |
QueryStringBehavior | Determines whether any query strings are included in the cache key and automatically included in requests that CloudFront sends to the origin. |
Properties
CachePolicyName
A unique name to identify the cache policy.
virtual string CachePolicyName { get; }
Property Value
System.String
Remarks
The name must only include '-', '_', or alphanumeric characters.
Default: - generated from the id
Comment
A comment to describe the cache policy.
virtual string Comment { get; }
Property Value
System.String
Remarks
The comment cannot be longer than 128 characters.
Default: - no comment
CookieBehavior
Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin.
virtual CacheCookieBehavior CookieBehavior { get; }
Property Value
Remarks
Default: CacheCookieBehavior.none()
DefaultTtl
The default amount of time for objects to stay in the CloudFront cache.
virtual Duration DefaultTtl { get; }
Property Value
Remarks
Only used when the origin does not send Cache-Control or Expires headers with the object.
Default: - The greater of 1 day and minTtl
EnableAcceptEncodingBrotli
Whether to normalize and include the Accept-Encoding
header in the cache key when the Accept-Encoding
header is 'br'.
virtual Nullable<bool> EnableAcceptEncodingBrotli { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
EnableAcceptEncodingGzip
Whether to normalize and include the Accept-Encoding
header in the cache key when the Accept-Encoding
header is 'gzip'.
virtual Nullable<bool> EnableAcceptEncodingGzip { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
HeaderBehavior
Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin.
virtual CacheHeaderBehavior HeaderBehavior { get; }
Property Value
Remarks
Default: CacheHeaderBehavior.none()
MaxTtl
The maximum amount of time for objects to stay in the CloudFront cache.
virtual Duration MaxTtl { get; }
Property Value
Remarks
CloudFront uses this value only when the origin sends Cache-Control or Expires headers with the object.
Default: - The greater of 1 year and defaultTtl
MinTtl
The minimum amount of time for objects to stay in the CloudFront cache.
virtual Duration MinTtl { get; }
Property Value
Remarks
Default: Duration.seconds(0)
QueryStringBehavior
Determines whether any query strings are included in the cache key and automatically included in requests that CloudFront sends to the origin.
virtual CacheQueryStringBehavior QueryStringBehavior { get; }
Property Value
Remarks
Default: CacheQueryStringBehavior.none()