diff --git a/apps/web/src/routes/dashboard.ts b/apps/web/src/routes/dashboard.ts index 5947f6b..4e1d465 100644 --- a/apps/web/src/routes/dashboard.ts +++ b/apps/web/src/routes/dashboard.ts @@ -4,6 +4,11 @@ import { resolve } from "path"; import { resolveKey } from "./auth"; import sql from "../db"; import { sparkline } from "../utils/sparkline"; +import { createHash } from "crypto"; + +// Generate a cache-buster hash from the CSS file content at startup +const cssFile = Bun.file(resolve(import.meta.dir, "../dashboard/tailwind.css")); +const cssHash = createHash("md5").update(await cssFile.bytes()).digest("hex").slice(0, 8); const eta = new Eta({ views: resolve(import.meta.dir, "../views"), cache: true, defaultExtension: ".ejs" }); @@ -56,7 +61,7 @@ function escapeHtmlSSR(str: string): string { } function html(template: string, data: Record = {}) { - return new Response(eta.render(template, { ...data, timeAgoSSR, sparklineSSR, latencyChartSSR, escapeHtmlSSR }), { + return new Response(eta.render(template, { ...data, timeAgoSSR, sparklineSSR, latencyChartSSR, escapeHtmlSSR, cssHash }), { headers: { "content-type": "text/html; charset=utf-8" }, }); } diff --git a/apps/web/src/views/partials/head.ejs b/apps/web/src/views/partials/head.ejs index 25fbaf8..cf767b0 100644 --- a/apps/web/src/views/partials/head.ejs +++ b/apps/web/src/views/partials/head.ejs @@ -4,9 +4,9 @@ PingQL<%= it.title ? ` — ${it.title}` : '' %> - - - + + + <% if (it.scripts) { it.scripts.forEach(function(s) { %> <% }) } %>