UNPKG

8.06 kBTypeScriptView Raw
1import { Duration, Resource } from '@aws-cdk/core';
2import { Construct } from 'constructs';
3/**
4 * Represents a Cache Policy
5 */
6export interface ICachePolicy {
7 /**
8 * The ID of the cache policy
9 * @attribute
10 */
11 readonly cachePolicyId: string;
12}
13/**
14 * Properties for creating a Cache Policy
15 */
16export interface CachePolicyProps {
17 /**
18 * A unique name to identify the cache policy.
19 * The name must only include '-', '_', or alphanumeric characters.
20 * @default - generated from the `id`
21 */
22 readonly cachePolicyName?: string;
23 /**
24 * A comment to describe the cache policy.
25 * @default - no comment
26 */
27 readonly comment?: string;
28 /**
29 * The default amount of time for objects to stay in the CloudFront cache.
30 * Only used when the origin does not send Cache-Control or Expires headers with the object.
31 * @default - The greater of 1 day and ``minTtl``
32 */
33 readonly defaultTtl?: Duration;
34 /**
35 * The minimum amount of time for objects to stay in the CloudFront cache.
36 * @default Duration.seconds(0)
37 */
38 readonly minTtl?: Duration;
39 /**
40 * The maximum amount of time for objects to stay in the CloudFront cache.
41 * CloudFront uses this value only when the origin sends Cache-Control or Expires headers with the object.
42 * @default - The greater of 1 year and ``defaultTtl``
43 */
44 readonly maxTtl?: Duration;
45 /**
46 * Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin.
47 * @default CacheCookieBehavior.none()
48 */
49 readonly cookieBehavior?: CacheCookieBehavior;
50 /**
51 * Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin.
52 * @default CacheHeaderBehavior.none()
53 */
54 readonly headerBehavior?: CacheHeaderBehavior;
55 /**
56 * Determines whether any query strings are included in the cache key and automatically included in requests that CloudFront sends to the origin.
57 * @default CacheQueryStringBehavior.none()
58 */
59 readonly queryStringBehavior?: CacheQueryStringBehavior;
60 /**
61 * Whether to normalize and include the `Accept-Encoding` header in the cache key when the `Accept-Encoding` header is 'gzip'.
62 * @default false
63 */
64 readonly enableAcceptEncodingGzip?: boolean;
65 /**
66 * Whether to normalize and include the `Accept-Encoding` header in the cache key when the `Accept-Encoding` header is 'br'.
67 * @default false
68 */
69 readonly enableAcceptEncodingBrotli?: boolean;
70}
71/**
72 * A Cache Policy configuration.
73 *
74 * @resource AWS::CloudFront::CachePolicy
75 * @link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
76 */
77export declare class CachePolicy extends Resource implements ICachePolicy {
78 /**
79 * This policy is designed for use with an origin that is an AWS Amplify web app.
80 */
81 static readonly AMPLIFY: ICachePolicy;
82 /**
83 * Optimize cache efficiency by minimizing the values that CloudFront includes in the cache key.
84 * Query strings and cookies are not included in the cache key, and only the normalized 'Accept-Encoding' header is included.
85 */
86 static readonly CACHING_OPTIMIZED: ICachePolicy;
87 /**
88 * Optimize cache efficiency by minimizing the values that CloudFront includes in the cache key.
89 * Query strings and cookies are not included in the cache key, and only the normalized 'Accept-Encoding' header is included.
90 * Disables cache compression.
91 */
92 static readonly CACHING_OPTIMIZED_FOR_UNCOMPRESSED_OBJECTS: ICachePolicy;
93 /** Disables caching. This policy is useful for dynamic content and for requests that are not cacheable. */
94 static readonly CACHING_DISABLED: ICachePolicy;
95 /** Designed for use with an origin that is an AWS Elemental MediaPackage endpoint. */
96 static readonly ELEMENTAL_MEDIA_PACKAGE: ICachePolicy;
97 /** Imports a Cache Policy from its id. */
98 static fromCachePolicyId(scope: Construct, id: string, cachePolicyId: string): ICachePolicy;
99 /** Use an existing managed cache policy. */
100 private static fromManagedCachePolicy;
101 readonly cachePolicyId: string;
102 constructor(scope: Construct, id: string, props?: CachePolicyProps);
103 private renderCacheKey;
104}
105/**
106 * Determines whether any cookies in viewer requests are included in the cache key and
107 * automatically included in requests that CloudFront sends to the origin.
108 */
109export declare class CacheCookieBehavior {
110 /**
111 * Cookies in viewer requests are not included in the cache key and
112 * are not automatically included in requests that CloudFront sends to the origin.
113 */
114 static none(): CacheCookieBehavior;
115 /**
116 * All cookies in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
117 */
118 static all(): CacheCookieBehavior;
119 /**
120 * Only the provided `cookies` are included in the cache key and automatically included in requests that CloudFront sends to the origin.
121 */
122 static allowList(...cookies: string[]): CacheCookieBehavior;
123 /**
124 * All cookies except the provided `cookies` are included in the cache key and
125 * automatically included in requests that CloudFront sends to the origin.
126 */
127 static denyList(...cookies: string[]): CacheCookieBehavior;
128 /** The behavior of cookies: allow all, none, an allow list, or a deny list. */
129 readonly behavior: string;
130 /** The cookies to allow or deny, if the behavior is an allow or deny list. */
131 readonly cookies?: string[];
132 private constructor();
133}
134/**
135 * Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin.
136 */
137export declare class CacheHeaderBehavior {
138 /** HTTP headers are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin. */
139 static none(): CacheHeaderBehavior;
140 /** Listed headers are included in the cache key and are automatically included in requests that CloudFront sends to the origin. */
141 static allowList(...headers: string[]): CacheHeaderBehavior;
142 /** If no headers will be passed, or an allow list of headers. */
143 readonly behavior: string;
144 /** The headers for the allow/deny list, if applicable. */
145 readonly headers?: string[];
146 private constructor();
147}
148/**
149 * Determines whether any URL query strings in viewer requests are included in the cache key
150 * and automatically included in requests that CloudFront sends to the origin.
151 */
152export declare class CacheQueryStringBehavior {
153 /**
154 * Query strings in viewer requests are not included in the cache key and
155 * are not automatically included in requests that CloudFront sends to the origin.
156 */
157 static none(): CacheQueryStringBehavior;
158 /**
159 * All query strings in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
160 */
161 static all(): CacheQueryStringBehavior;
162 /**
163 * Only the provided `queryStrings` are included in the cache key and automatically included in requests that CloudFront sends to the origin.
164 */
165 static allowList(...queryStrings: string[]): CacheQueryStringBehavior;
166 /**
167 * All query strings except the provided `queryStrings` are included in the cache key and
168 * automatically included in requests that CloudFront sends to the origin.
169 */
170 static denyList(...queryStrings: string[]): CacheQueryStringBehavior;
171 /** The behavior of query strings -- allow all, none, only an allow list, or a deny list. */
172 readonly behavior: string;
173 /** The query strings to allow or deny, if the behavior is an allow or deny list. */
174 readonly queryStrings?: string[];
175 private constructor();
176}