@cloudflare/pages-shared 0.13.1 → 0.13.2
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/asset-server/handler.ts +4 -2
- package/package.json +1 -1
package/asset-server/handler.ts
CHANGED
|
@@ -347,6 +347,7 @@ export async function generateHandler<
|
|
|
347
347
|
|
|
348
348
|
async function attachHeaders(response: Response) {
|
|
349
349
|
const existingHeaders = new Headers(response.headers);
|
|
350
|
+
const eTag = existingHeaders.get("eTag")?.match(/^"(.*)"$/)?.[1];
|
|
350
351
|
|
|
351
352
|
const extraHeaders = new Headers({
|
|
352
353
|
"access-control-allow-origin": "*",
|
|
@@ -364,13 +365,14 @@ export async function generateHandler<
|
|
|
364
365
|
|
|
365
366
|
if (
|
|
366
367
|
earlyHintsCache &&
|
|
367
|
-
isHTMLContentType(response.headers.get("Content-Type"))
|
|
368
|
+
isHTMLContentType(response.headers.get("Content-Type")) &&
|
|
369
|
+
eTag
|
|
368
370
|
) {
|
|
369
371
|
const preEarlyHintsHeaders = new Headers(headers);
|
|
370
372
|
|
|
371
373
|
// "Early Hints cache entries are keyed by request URI and ignore query strings."
|
|
372
374
|
// https://developers.cloudflare.com/cache/about/early-hints/
|
|
373
|
-
const earlyHintsCacheKey = `${protocol}//${host}
|
|
375
|
+
const earlyHintsCacheKey = `${protocol}//${host}/${eTag}`;
|
|
374
376
|
const earlyHintsResponse =
|
|
375
377
|
await earlyHintsCache.match(earlyHintsCacheKey);
|
|
376
378
|
if (earlyHintsResponse) {
|