Class CachePolicy.Builder

java.lang.Object
software.amazon.awscdk.services.cloudfront.CachePolicy.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<CachePolicy>
Enclosing class:
CachePolicy

@Stability(Stable) public static final class CachePolicy.Builder extends Object implements software.amazon.jsii.Builder<CachePolicy>
A fluent builder for CachePolicy.
  • Method Details

    • create

      @Stability(Stable) public static CachePolicy.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of CachePolicy.Builder.
    • cachePolicyName

      @Stability(Stable) public CachePolicy.Builder cachePolicyName(String cachePolicyName)
      A unique name to identify the cache policy.

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

      Default: - generated from the `id`

      Parameters:
      cachePolicyName - A unique name to identify the cache policy. This parameter is required.
      Returns:
      this
    • comment

      @Stability(Stable) public CachePolicy.Builder comment(String comment)
      A comment to describe the cache policy.

      Default: - no comment

      Parameters:
      comment - A comment to describe the cache policy. This parameter is required.
      Returns:
      this
    • cookieBehavior

      @Stability(Stable) public CachePolicy.Builder cookieBehavior(CacheCookieBehavior 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.

      Default: CacheCookieBehavior.none()

      Parameters:
      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. This parameter is required.
      Returns:
      this
    • defaultTtl

      @Stability(Stable) public CachePolicy.Builder defaultTtl(Duration defaultTtl)
      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``

      Parameters:
      defaultTtl - The default amount of time for objects to stay in the CloudFront cache. This parameter is required.
      Returns:
      this
    • enableAcceptEncodingBrotli

      @Stability(Stable) public CachePolicy.Builder enableAcceptEncodingBrotli(Boolean enableAcceptEncodingBrotli)
      Whether to normalize and include the Accept-Encoding header in the cache key when the Accept-Encoding header is 'br'.

      Default: false

      Parameters:
      enableAcceptEncodingBrotli - Whether to normalize and include the Accept-Encoding header in the cache key when the Accept-Encoding header is 'br'. This parameter is required.
      Returns:
      this
    • enableAcceptEncodingGzip

      @Stability(Stable) public CachePolicy.Builder enableAcceptEncodingGzip(Boolean enableAcceptEncodingGzip)
      Whether to normalize and include the Accept-Encoding header in the cache key when the Accept-Encoding header is 'gzip'.

      Default: false

      Parameters:
      enableAcceptEncodingGzip - Whether to normalize and include the Accept-Encoding header in the cache key when the Accept-Encoding header is 'gzip'. This parameter is required.
      Returns:
      this
    • headerBehavior

      @Stability(Stable) public CachePolicy.Builder headerBehavior(CacheHeaderBehavior headerBehavior)
      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()

      Parameters:
      headerBehavior - Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. This parameter is required.
      Returns:
      this
    • maxTtl

      @Stability(Stable) public CachePolicy.Builder maxTtl(Duration maxTtl)
      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``

      Parameters:
      maxTtl - The maximum amount of time for objects to stay in the CloudFront cache. This parameter is required.
      Returns:
      this
    • minTtl

      @Stability(Stable) public CachePolicy.Builder minTtl(Duration minTtl)
      The minimum amount of time for objects to stay in the CloudFront cache.

      Default: Duration.seconds(0)

      Parameters:
      minTtl - The minimum amount of time for objects to stay in the CloudFront cache. This parameter is required.
      Returns:
      this
    • queryStringBehavior

      @Stability(Stable) public CachePolicy.Builder queryStringBehavior(CacheQueryStringBehavior queryStringBehavior)
      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()

      Parameters:
      queryStringBehavior - Determines whether any query strings are included in the cache key and automatically included in requests that CloudFront sends to the origin. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public CachePolicy build()
      Specified by:
      build in interface software.amazon.jsii.Builder<CachePolicy>
      Returns:
      a newly built instance of CachePolicy.