Interface CachePolicyProps

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
CachePolicyProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-18T17:54:13.601Z") @Stability(Stable) public interface CachePolicyProps extends software.amazon.jsii.JsiiSerializable
Properties for creating a Cache Policy.

Example:

 // Creating a custom cache policy for a Distribution -- all parameters optional
 S3Origin bucketOrigin;
 CachePolicy myCachePolicy = CachePolicy.Builder.create(this, "myCachePolicy")
         .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)
         .build();
 Distribution.Builder.create(this, "myDistCustomPolicy")
         .defaultBehavior(BehaviorOptions.builder()
                 .origin(bucketOrigin)
                 .cachePolicy(myCachePolicy)
                 .build())
         .build();
 
  • Method Details

    • getCachePolicyName

      @Stability(Stable) @Nullable default String getCachePolicyName()
      A unique name to identify the cache policy.

      The name must only include '-', '_', or alphanumeric characters.

      Default: - generated from the `id`

    • getComment

      @Stability(Stable) @Nullable default String getComment()
      A comment to describe the cache policy.

      Default: - no comment

    • getCookieBehavior

      @Stability(Stable) @Nullable default CacheCookieBehavior getCookieBehavior()
      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()

    • getDefaultTtl

      @Stability(Stable) @Nullable default Duration getDefaultTtl()
      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 and ``minTtl``

    • getEnableAcceptEncodingBrotli

      @Stability(Stable) @Nullable default Boolean getEnableAcceptEncodingBrotli()
      Whether to normalize and include the Accept-Encoding header in the cache key when the Accept-Encoding header is 'br'.

      Default: false

    • getEnableAcceptEncodingGzip

      @Stability(Stable) @Nullable default Boolean getEnableAcceptEncodingGzip()
      Whether to normalize and include the Accept-Encoding header in the cache key when the Accept-Encoding header is 'gzip'.

      Default: false

    • getHeaderBehavior

      @Stability(Stable) @Nullable default CacheHeaderBehavior getHeaderBehavior()
      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()

    • getMaxTtl

      @Stability(Stable) @Nullable default Duration getMaxTtl()
      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 and ``defaultTtl``

    • getMinTtl

      @Stability(Stable) @Nullable default Duration getMinTtl()
      The minimum amount of time for objects to stay in the CloudFront cache.

      Default: Duration.seconds(0)

    • getQueryStringBehavior

      @Stability(Stable) @Nullable default CacheQueryStringBehavior getQueryStringBehavior()
      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()

    • builder

      @Stability(Stable) static CachePolicyProps.Builder builder()
      Returns:
      a CachePolicyProps.Builder of CachePolicyProps