Class CachePolicyProps
Properties for creating a Cache Policy.
Inheritance
Implements
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.AWS.CloudFront.dll
Syntax (csharp)
public class CachePolicyProps : Object, ICachePolicyProps
Syntax (vb)
Public Class CachePolicyProps
Inherits Object
Implements 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
Constructors
CachePolicyProps() |
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. |
Constructors
CachePolicyProps()
public CachePolicyProps()
Properties
CachePolicyName
A unique name to identify the cache policy.
public string CachePolicyName { get; set; }
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.
public string Comment { get; set; }
Property Value
System.String
Remarks
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.
public CacheCookieBehavior CookieBehavior { get; set; }
Property Value
Remarks
Default: CacheCookieBehavior.none()
DefaultTtl
The default amount of time for objects to stay in the CloudFront cache.
public Duration DefaultTtl { get; set; }
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'.
public Nullable<bool> EnableAcceptEncodingBrotli { get; set; }
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'.
public Nullable<bool> EnableAcceptEncodingGzip { get; set; }
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.
public CacheHeaderBehavior HeaderBehavior { get; set; }
Property Value
Remarks
Default: CacheHeaderBehavior.none()
MaxTtl
The maximum amount of time for objects to stay in the CloudFront cache.
public Duration MaxTtl { get; set; }
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.
public Duration MinTtl { get; set; }
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.
public CacheQueryStringBehavior QueryStringBehavior { get; set; }
Property Value
Remarks
Default: CacheQueryStringBehavior.none()