@cloudflare/pages-shared 0.11.37 → 0.11.38
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 +13 -1
- package/package.json +1 -1
package/asset-server/handler.ts
CHANGED
|
@@ -492,7 +492,19 @@ export async function generateHandler<
|
|
|
492
492
|
if (responseWithoutHeaders.status >= 500) {
|
|
493
493
|
return responseWithoutHeaders;
|
|
494
494
|
}
|
|
495
|
-
|
|
495
|
+
|
|
496
|
+
const responseWithHeaders = await attachHeaders(responseWithoutHeaders);
|
|
497
|
+
if (responseWithHeaders.status === 404) {
|
|
498
|
+
// Remove any user-controlled cache-control headers
|
|
499
|
+
// This is to prevent the footgun of potentionally caching this 404 for a long time
|
|
500
|
+
if (responseWithHeaders.headers.has("cache-control")) {
|
|
501
|
+
responseWithHeaders.headers.delete("cache-control");
|
|
502
|
+
}
|
|
503
|
+
// Add cache-control: no-store to prevent this from being cached on the responding zones.
|
|
504
|
+
responseWithHeaders.headers.append("cache-control", "no-store");
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return responseWithHeaders;
|
|
496
508
|
|
|
497
509
|
async function serveAsset(
|
|
498
510
|
servingAssetEntry: AssetEntry,
|