Skip to content

Commit e2afd4f

Browse files
committed
feat(workers): ?nocache param to force screenshot re-render
Appending ?nocache to a .png URL bypasses the edge cache and returns Cache-Control: no-store, ensuring a fresh browser render.
1 parent 0d38702 commit e2afd4f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

workers/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default {
6565
const width = Math.min(Math.max(Number(url.searchParams.get("w")) || 800, 320), 1920);
6666
const theme = url.searchParams.get("theme");
6767
const mode = url.searchParams.get("mode") === "dark" ? "dark" : "light";
68+
const noCache = url.searchParams.has("nocache");
6869

6970
const checkUrl = new URL(url);
7071
checkUrl.pathname = `/s/${pngMatch[1]}`;
@@ -86,7 +87,10 @@ export default {
8687
cookies: [{ name: "sideshow_key", value: env.SIDESHOW_TOKEN, domain: url.hostname }],
8788
});
8889
return new Response(await screenshot.arrayBuffer(), {
89-
headers: { "Content-Type": "image/png", "Cache-Control": "public, max-age=300" },
90+
headers: {
91+
"Content-Type": "image/png",
92+
"Cache-Control": noCache ? "no-store" : "public, max-age=300",
93+
},
9094
});
9195
},
9296
} satisfies ExportedHandler<Env>;

0 commit comments

Comments
 (0)