Commit d62e473
committed
Add cache headers to applet bundles and workspace file streams
Both the applet-bundle route and the workspace media-file (`fileUrl`)
route sent NO cache headers, so a TLS-terminating reverse proxy
(Cloudflare) applied its default extension-based edge caching. The stable
`index.js` entry url then served a stale bundle after every `moi bundle`,
and private workspace media could be stored on a shared edge.
Split caching by whether the url is stable or content-hashed:
- Applet entry `index.js` (stable url across rebuilds): ETag from
(size, mtime) + `no-cache`, with 304 on `If-None-Match`. The edge must
revalidate, so an unchanged bundle costs a 304 and a rebuilt one busts —
no more stale bundles behind a proxy.
- Applet chunks/assets (`chunk-<hash>.js`, `<stem>-<hash>.<ext>`): the url
is a fingerprint of the bytes, so `public, max-age=31536000, immutable`.
Cached forever at edge and browser (mirrors the SPA chunks).
- Workspace media (`/fs/*`): the user's own, mutable files — `private,
no-cache` + ETag (304 on match) so they are NEVER stored by a shared
edge and the browser revalidates cheaply. Headers ride the 200, 206 and
304 paths. Mirrors the existing `/preview/*` route.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpGBXW5iHAsc8K2543Z7BU1 parent a50cb8b commit d62e473
5 files changed
Lines changed: 133 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
142 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
143 | 159 | | |
144 | 160 | | |
145 | 161 | | |
146 | 162 | | |
147 | 163 | | |
148 | | - | |
| 164 | + | |
| 165 | + | |
149 | 166 | | |
150 | 167 | | |
151 | 168 | | |
| |||
160 | 177 | | |
161 | 178 | | |
162 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
163 | 188 | | |
164 | 189 | | |
165 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
166 | 193 | | |
167 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
168 | 200 | | |
169 | 201 | | |
170 | 202 | | |
| |||
255 | 287 | | |
256 | 288 | | |
257 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
258 | 298 | | |
259 | 299 | | |
260 | 300 | | |
261 | | - | |
| 301 | + | |
| 302 | + | |
262 | 303 | | |
263 | 304 | | |
264 | 305 | | |
265 | 306 | | |
266 | 307 | | |
267 | 308 | | |
268 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
269 | 315 | | |
270 | 316 | | |
271 | 317 | | |
272 | 318 | | |
273 | 319 | | |
274 | | - | |
| 320 | + | |
275 | 321 | | |
276 | 322 | | |
277 | 323 | | |
278 | 324 | | |
279 | 325 | | |
280 | 326 | | |
281 | 327 | | |
| 328 | + | |
282 | 329 | | |
283 | 330 | | |
284 | 331 | | |
| |||
287 | 334 | | |
288 | 335 | | |
289 | 336 | | |
290 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
291 | 343 | | |
292 | 344 | | |
293 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
78 | 117 | | |
79 | 118 | | |
80 | 119 | | |
| |||
164 | 203 | | |
165 | 204 | | |
166 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
167 | 231 | | |
168 | 232 | | |
169 | 233 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
162 | 163 | | |
163 | | - | |
| 164 | + | |
164 | 165 | | |
0 commit comments