kempo 4.2.28 → 4.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/middleware/kempo.js +9 -2
- package/package.json +1 -1
package/middleware/kempo.js
CHANGED
|
@@ -212,16 +212,23 @@ export default config => {
|
|
|
212
212
|
Revalidated rather than immutable. The URL carries lexical's version but not kempo's, so
|
|
213
213
|
rebuilding kempo changes what lives at the same URL, and caching that for a year would
|
|
214
214
|
strand every client on a stale bundle. A 304 costs almost nothing.
|
|
215
|
+
|
|
216
|
+
`no-cache`, not `must-revalidate` alone: without an explicit max-age, must-revalidate
|
|
217
|
+
leaves freshness to the browser's heuristics, and a heuristically-fresh entry is served
|
|
218
|
+
straight from disk cache with no conditional request at all — so a stale entry chunk can
|
|
219
|
+
keep pointing at a chunk hash a rebuild already deleted, breaking the editor with no
|
|
220
|
+
network request to observe. no-cache forces a conditional GET on every load regardless of
|
|
221
|
+
heuristic freshness, so a rebuild is always picked up via the ETag check above.
|
|
215
222
|
*/
|
|
216
223
|
const etag = `"${info.size}-${Math.floor(info.mtimeMs)}"`;
|
|
217
224
|
if(request.headers['if-none-match'] === etag){
|
|
218
|
-
response.writeHead(304, { ETag: etag, 'Cache-Control': 'public,
|
|
225
|
+
response.writeHead(304, { ETag: etag, 'Cache-Control': 'public, no-cache' });
|
|
219
226
|
response.end();
|
|
220
227
|
return;
|
|
221
228
|
}
|
|
222
229
|
response.writeHead(200, {
|
|
223
230
|
'Content-Type': 'application/javascript; charset=utf-8',
|
|
224
|
-
'Cache-Control': 'public,
|
|
231
|
+
'Cache-Control': 'public, no-cache',
|
|
225
232
|
ETag: etag,
|
|
226
233
|
});
|
|
227
234
|
response.end(await readFile(file));
|