From 9c138199ffa7ddad4a688ef35407b5b02c485ef0 Mon Sep 17 00:00:00 2001 From: adamXbot <111877622+adamXbot@users.noreply.github.com> Date: Wed, 4 Nov 2026 00:29:10 +1100 Subject: [PATCH] ops: static uptime probe at /ratchet Blackbox probes the homepage every couple of minutes, and each probe renders the page in the Worker; that rhythm tripped the Workers Free plan's 10 ms CPU limit. A static file is answered before the Worker runs, so it costs nothing. public/_headers types it, keeps it uncached so each probe reaches the asset store, and hides it from search. The test checks the built bundle. Co-Authored-By: Claude Fable 5.1 --- public/_headers | 9 +++++++++ public/ratchet | 1 + scripts/check-site.mjs | 9 +++++++++ tests/site.test.mjs | 12 ++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 public/ratchet diff --git a/public/_headers b/public/_headers index 9ba5dc3..15eae06 100644 --- a/public/_headers +++ b/public/_headers @@ -34,3 +34,12 @@ /evidence/* Cache-Control: public, max-age=3600 + +# Uptime probe: Blackbox fetches /ratchet every minute. A static file is +# answered before the Worker runs, so the probe costs no CPU (a homepage probe +# renders the page each time). Typed and uncached here so every probe reaches +# the asset store, not an edge cache. +/ratchet + Content-Type: text/plain; charset=utf-8 + Cache-Control: no-cache, max-age=0, must-revalidate + X-Robots-Tag: noindex diff --git a/public/ratchet b/public/ratchet new file mode 100644 index 0000000..1c2b866 --- /dev/null +++ b/public/ratchet @@ -0,0 +1 @@ +clank diff --git a/scripts/check-site.mjs b/scripts/check-site.mjs index cd3b7cc..5418fec 100644 --- a/scripts/check-site.mjs +++ b/scripts/check-site.mjs @@ -323,6 +323,15 @@ assert.equal( await installer.text(), await fs.readFile(new URL('../public/install.sh', import.meta.url), 'utf8'), ); +// The uptime probe is a static file: no Worker CPU per fetch, typed and +// uncached by public/_headers. +const probe = await fetch(new URL('/ratchet', base), { redirect: 'manual' }); +assert.equal(probe.status, 200, 'uptime probe'); +assert.equal((await probe.text()).trim(), 'clank', 'uptime probe body'); +assert.match(probe.headers.get('content-type') || '', /^text\/plain/); +assert.match(probe.headers.get('cache-control') || '', /no-cache/); +assertSecurityHeaders(probe, '/ratchet'); +assert.equal(probe.headers.get('x-robots-tag'), 'noindex'); const robots = await fetch(new URL('/robots.txt', base)); assert.equal(robots.status, 200); assert.match( diff --git a/tests/site.test.mjs b/tests/site.test.mjs index bc06741..732dc08 100644 --- a/tests/site.test.mjs +++ b/tests/site.test.mjs @@ -442,3 +442,15 @@ test('the Worker answers only on fxcss.com and uploads no repository metadata', ); } }); + +test('the uptime probe is a static file with its own headers', () => { + // Blackbox fetches /ratchet every minute. Served before the Worker runs it + // costs no CPU, which a homepage probe does not; public/_headers types it + // and keeps it uncached so every probe reaches the asset store. + assert.equal(read('../public/ratchet').toString().trim(), 'clank'); + const headers = read('../public/_headers').toString(); + const rule = headers.match(/^\/ratchet\n((?:[ \t]+\S.*\n?)+)/m)?.[1] ?? ''; + assert.match(rule, /Content-Type: text\/plain; charset=utf-8/); + assert.match(rule, /Cache-Control: no-cache/); + assert.match(rule, /X-Robots-Tag: noindex/); +});