1
1
declare 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
+
2
49
/**
3
50
* Configures the caching behavior of a {@linkcode "globals".Response}.
4
51
*
@@ -17,8 +64,6 @@ declare module 'fastly:cache-override' {
17
64
* "origins": [
18
65
* "https://http-me.glitch.me"
19
66
* ],
20
- * "src": {
21
- * "deps": "{\n \"@fastly /js-compute\": \"^0.7.0\"\n }",
22
67
* "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"
23
68
* },
24
69
* "requests": [
@@ -64,6 +109,7 @@ declare module 'fastly:cache-override' {
64
109
* ```
65
110
* </noscript>
66
111
*/
112
+
67
113
class CacheOverride {
68
114
/**
69
115
* @param mode Sets the cache override mode for a request
@@ -73,41 +119,12 @@ declare module 'fastly:cache-override' {
73
119
* - "pass": Do not cache the response to this request, regardless of the origin response’s headers.
74
120
* - "override": Override particular cache control settings using a {@linkcode CacheOverride} object.
75
121
*
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
95
123
*
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.
101
124
*/
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 ;
111
128
112
129
/**
113
130
* Sets the cache override mode for a request
@@ -121,20 +138,28 @@ declare module 'fastly:cache-override' {
121
138
/**
122
139
* Override the caching behavior of this request to use the given Time to Live (TTL), in seconds.
123
140
*/
124
- public ttl ? : number ;
141
+ public ttl : number | undefined ;
125
142
/**
126
143
* Override the caching behavior of this request to use the given `stale-while-revalidate` time,
127
144
* in seconds
128
145
*/
129
- public swr ? : number ;
146
+ public swr : number | undefined ;
130
147
/**
131
148
* Override the caching behavior of this request to include the given surrogate key, provided as
132
149
* a header value.
133
150
*
134
151
* See the [Fastly surrogate keys guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys)
135
152
* for details.
136
153
*/
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 ;
138
163
/**
139
164
* Override the caching behavior of this request to enable or disable PCI/HIPAA-compliant
140
165
* non-volatile caching.
@@ -145,6 +170,10 @@ declare module 'fastly:cache-override' {
145
170
* See the [Fastly PCI-Compliant Caching and Delivery documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery)
146
171
* for details.
147
172
*/
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 ;
149
178
}
150
179
}
0 commit comments