diff --git a/apps/status/src/index.ts b/apps/status/src/index.ts index ef4e932..72ba53b 100644 --- a/apps/status/src/index.ts +++ b/apps/status/src/index.ts @@ -50,7 +50,7 @@ function splitSlugAndFormat(raw: string): { slug: string; format: "html" | "json } async function renderHtml(slug: string, request: Request): Promise { - const page = await cached(`page:${slug}`, 60, () => loadStatusPage(slug)); + const page = await cached(`page:${slug}`, 15, () => loadStatusPage(slug)); if (!page) return notFound(); if (!isAuthorised(page, request)) { return new Response(eta.render("password", { title: page.title, slug: page.slug, error: null }), { @@ -58,12 +58,12 @@ async function renderHtml(slug: string, request: Request): Promise { headers: { "content-type": "text/html; charset=utf-8" }, }); } - const payload = await cached(`payload:${slug}`, 60, () => loadPagePayload(slug)); + const payload = await cached(`payload:${slug}`, 15, () => loadPagePayload(slug)); if (!payload) return notFound(); const html = eta.render("page", payload); const headers: Record = { "content-type": "text/html; charset=utf-8", - "cache-control": "public, max-age=30, s-maxage=60", + "cache-control": "public, max-age=15, s-maxage=15", "x-frame-options":"SAMEORIGIN", "x-content-type-options": "nosniff", "referrer-policy":"strict-origin-when-cross-origin", @@ -73,16 +73,16 @@ async function renderHtml(slug: string, request: Request): Promise { } async function renderJson(slug: string, request: Request, win?: Window): Promise { - const page = await cached(`page:${slug}`, 60, () => loadStatusPage(slug)); + const page = await cached(`page:${slug}`, 15, () => loadStatusPage(slug)); if (!page) return new Response(JSON.stringify({ error: "not found" }), { status: 404, headers: { "content-type": "application/json" } }); if (!isAuthorised(page, request)) return new Response(JSON.stringify({ error: "password required" }), { status: 401, headers: { "content-type": "application/json" } }); const cacheKey = `payload:${slug}:${win ?? page.default_window}`; - const payload = await cached(cacheKey, 60, () => loadPagePayload(slug, win)); + const payload = await cached(cacheKey, 15, () => loadPagePayload(slug, win)); if (!payload) return new Response(JSON.stringify({ error: "not found" }), { status: 404, headers: { "content-type": "application/json" } }); return new Response(JSON.stringify(payload), { headers: { "content-type": "application/json", - "cache-control": "public, max-age=30, s-maxage=60", + "cache-control": "public, max-age=15, s-maxage=15", ...(page.index_search ? {} : { "x-robots-tag": "noindex, nofollow" }), }, }); @@ -117,14 +117,14 @@ const app = new Elysia() // Public SVG badge .get("/:slug/badge.svg", async ({ params, request }) => { if (!allow(params.slug, clientIp(request))) return rateLimited(); - const payload = await cached(`payload:${params.slug}`, 60, () => loadPagePayload(params.slug)); + const payload = await cached(`payload:${params.slug}`, 15, () => loadPagePayload(params.slug)); if (!payload) return notFound(); const { message, color } = badgeFromState(payload.monitors); const svg = renderBadge("status", message, color); return new Response(svg, { headers: { "content-type": "image/svg+xml", - "cache-control": "public, max-age=60, s-maxage=60", + "cache-control": "public, max-age=15, s-maxage=15", }, }); }) @@ -139,7 +139,7 @@ const app = new Elysia() const monitorId = idWithExt.endsWith(".json") ? idWithExt.slice(0, -5) : idWithExt; const win = (query as any)?.window as Window | undefined; const cacheKey = `monitor:${params.slug}:${monitorId}:${win ?? ''}`; - const payload = await cached(cacheKey, 60, () => loadMonitorDetail(params.slug, monitorId, win)); + const payload = await cached(cacheKey, 15, () => loadMonitorDetail(params.slug, monitorId, win)); if (!payload) { return new Response(JSON.stringify({ error: "not found" }), { status: 404, @@ -149,7 +149,7 @@ const app = new Elysia() return new Response(JSON.stringify(payload), { headers: { "content-type": "application/json", - "cache-control": "public, max-age=30, s-maxage=60", + "cache-control": "public, max-age=15, s-maxage=15", }, }); }) diff --git a/apps/status/src/views/page.ejs b/apps/status/src/views/page.ejs index 1e4581b..0d10363 100644 --- a/apps/status/src/views/page.ejs +++ b/apps/status/src/views/page.ejs @@ -113,7 +113,7 @@ .monitor-name .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .monitor-meta { display: flex; gap: 1rem; align-items: center; font-size: 0.85rem; color: var(--muted); } .uptime-pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--fg); } - .bars { display: flex; gap: 2px; height: 32px; margin-top: 0.75rem; align-items: stretch; } + .bars { display: flex; gap: 0.1rem; height: 32px; margin-top: 0.75rem; align-items: stretch; } .bar { flex: 1; min-width: 0; border-radius: 2px; transition: opacity 0.15s; } .bar:hover { opacity: 0.8; } .bars-meta { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--muted); margin-top: 0.4rem; }