Disable HTML caching in static runtime responses

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 01:14:17 +00:00
1 parent 524ba15e62
commit fc16b8ac58
2 files changed
+13

No files matched your search

+7
View File
@@ -168,6 +168,13 @@ async function main() {
if (page.headers.get("x-content-type-options") !== "nosniff") {
throw new Error("Smoke test failed: expected x-content-type-options=nosniff.");
}
if ((page.headers.get("cache-control") ?? "").toLowerCase() !== "no-store") {
throw new Error(
`Smoke test failed: expected cache-control=no-store, got ${String(
page.headers.get("cache-control"),
)}.`,
);
}
const missingAssetUrl = new URL("/assets/missing-bundle.js", parsedAppUrl);
const missingAsset = await fetch(missingAssetUrl);
if (missingAsset.status !== 404) {
+6
View File
@@ -614,6 +614,9 @@ function startStaticWebServer(distRoot: string, port: number) {
response.setHeader("Content-Type", contentTypeFor(targetPath));
response.setHeader("Content-Length", String(stats.size));
response.setHeader("X-Content-Type-Options", "nosniff");
if (targetPath.endsWith(".html")) {
response.setHeader("Cache-Control", "no-store");
}
response.end();
});
return;
@@ -629,6 +632,9 @@ function startStaticWebServer(distRoot: string, port: number) {
response.setHeader("Content-Type", contentTypeFor(targetPath));
response.setHeader("X-Content-Type-Options", "nosniff");
response.setHeader("Content-Length", String(content.byteLength));
if (targetPath.endsWith(".html")) {
response.setHeader("Cache-Control", "no-store");
}
response.end(content);
});
});