11declare module 'fastly:cache-override' {
2+ interface ICacheOverride {
3+ /**
4+ * The cache key for this cache entry
5+ */
6+ cacheKey ?: string | undefined ;
7+ /**
8+ * Override the caching behavior of this request/response to use the given Time to Live (TTL), in seconds.
9+ */
10+ ttl ?: number | undefined ;
11+ /**
12+ * Override the caching behavior of this request/response to use the given `stale-while-revalidate` time,
13+ * in seconds
14+ */
15+ swr ?: number | undefined ;
16+ /**
17+ * Override the caching behavior of this request/response to include the given surrogate key, provided as
18+ * a header value.
19+ *
20+ * See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
21+ * for details.
22+ */
23+ surrogateKeys ?: Set < string > ;
24+ /**
25+ * Override the caching behavior of this request/response to include the given surrogate keys, provided as
26+ * a header value.
27+ *
28+ * See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
29+ * for details.
30+ */
31+ surrogateKey ?: string | undefined ;
32+ /**
33+ * Override the caching behavior of this request/response to enable or disable PCI/HIPAA-compliant
34+ * non-volatile caching.
35+ *
36+ * By default, this is false, which means the request may not be PCI/HIPAA-compliant. Set it to
37+ * true to enable compliant caching.
38+ *
39+ * See the [Fastly PCI-Compliant Caching and Delivery documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery)
40+ * for details.
41+ */
42+ pci ?: boolean ;
43+ /**
44+ * Get or set the set of request headers for which the response may vary.
45+ */
46+ vary ?: Set < string > ;
47+ }
48+
249 /**
350 * Configures the caching behavior of a {@linkcode "globals".Response}.
451 *
@@ -17,8 +64,6 @@ declare module 'fastly:cache-override' {
1764 * "origins": [
1865 * "https://http-me.glitch.me"
1966 * ],
20- * "src": {
21- * "deps": "{\n \"@fastly /js-compute\": \"^0.7.0\"\n }",
2267 * "main": "/// <reference types=\"@fastly /js-compute\" />\nimport { CacheOverride } from \"fastly:cache-override\";\n\n// In this example we override the cache for all the requests prefixed /static/ \n// to have a long TTL (Time To Live), and the home page to have a short TTL and \n// a long SWR (Stale While Revalidate).\nasync function app (event) {\n const path = (new URL(event.request.url)).pathname;\n let cacheOverride;\n if (path == '/') {\n cacheOverride = new CacheOverride('override', {ttl: 10, swr: 86_400});\n } else if (path.startsWith('/static/')) {\n cacheOverride = new CacheOverride('override', {ttl: 86_400});\n } else {\n cacheOverride = new CacheOverride('none')\n }\n return fetch(event.request.url, {\n cacheOverride,\n backend: 'origin_0'\n });\n }\naddEventListener(\"fetch\", event => event.respondWith(app(event)));\n"
2368 * },
2469 * "requests": [
@@ -64,6 +109,7 @@ declare module 'fastly:cache-override' {
64109 * ```
65110 * </noscript>
66111 */
112+
67113 class CacheOverride {
68114 /**
69115 * @param mode Sets the cache override mode for a request
@@ -73,41 +119,12 @@ declare module 'fastly:cache-override' {
73119 * - "pass": Do not cache the response to this request, regardless of the origin response’s headers.
74120 * - "override": Override particular cache control settings using a {@linkcode CacheOverride} object.
75121 *
76- * @param [init]
77- *
78- * @param {number } [init.ttl]
79- * Override the caching behavior of this request to use the given Time to Live (TTL), in seconds.
80- *
81- * @param {number } [init.swr]
82- * Override the caching behavior of this request to use the given `stale-while-revalidate` time,
83- * in seconds
84- *
85- * @param {string } [init.surrogateKey]
86- * Override the caching behavior of this request to include the given surrogate key, provided as
87- * a header value.
88- *
89- * See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
90- * for details.
91- *
92- * @param {boolean } [init.pci]
93- * Override the caching behavior of this request to enable or disable PCI/HIPAA-compliant
94- * non-volatile caching.
122+ * @param [init] Init options for the cache override
95123 *
96- * By default, this is false, which means the request may not be PCI/HIPAA-compliant. Set it to
97- * true to enable compliant caching.
98- *
99- * See the [Fastly PCI-Compliant Caching and Delivery documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery)
100- * for details.
101124 */
102- constructor (
103- mode : 'none' | 'pass' | 'override' ,
104- init ?: {
105- ttl ?: number ;
106- swr ?: number ;
107- surrogateKey ?: string ;
108- pci ?: boolean ;
109- } ,
110- ) ;
125+ constructor ( mode : 'none' | 'pass' | 'override' , init ?: ICacheOverride ) ;
126+
127+ cacheKey ?: string ;
111128
112129 /**
113130 * Sets the cache override mode for a request
@@ -121,20 +138,28 @@ declare module 'fastly:cache-override' {
121138 /**
122139 * Override the caching behavior of this request to use the given Time to Live (TTL), in seconds.
123140 */
124- public ttl ? : number ;
141+ public ttl : number | undefined ;
125142 /**
126143 * Override the caching behavior of this request to use the given `stale-while-revalidate` time,
127144 * in seconds
128145 */
129- public swr ? : number ;
146+ public swr : number | undefined ;
130147 /**
131148 * Override the caching behavior of this request to include the given surrogate key, provided as
132149 * a header value.
133150 *
134151 * See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
135152 * for details.
136153 */
137- public surrogateKey ?: string ;
154+ public surrogateKey : string | undefined ;
155+ /**
156+ * Override the caching behavior of this request to include the given surrogate key, provided as
157+ * a header value.
158+ *
159+ * See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
160+ * for details.
161+ */
162+ public surrogateKeys : Set < string > | undefined ;
138163 /**
139164 * Override the caching behavior of this request to enable or disable PCI/HIPAA-compliant
140165 * non-volatile caching.
@@ -145,6 +170,10 @@ declare module 'fastly:cache-override' {
145170 * See the [Fastly PCI-Compliant Caching and Delivery documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery)
146171 * for details.
147172 */
148- public pci ?: boolean ;
173+ public pci : boolean | undefined ;
174+ /**
175+ * Get or set the set of request headers for which the response may vary.
176+ */
177+ public vary : Set < string > | undefined ;
149178 }
150179}
0 commit comments