Serve the script as /app.js, cached until a deploy changes it

The page loaded its script inline. It now names /app.js?v=<hash> (login.js for
the sign-in page), the hash of the script's contents: the script is served
immutable for a year and the page no-cache, so a browser fetches the script
again only when a deploy changes it and so its name.

Also fixes a race in the mark-everything-read test: it waited on a badge that
was seldom 0 to begin with, so a mark-unread still in flight could land after
the read-all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-18 13:03:25 +00:00
parent e2969bcee8
commit 5483355021
7 changed files with 84 additions and 20 deletions

View File

@@ -62,8 +62,10 @@ the shell running the command and kills the session (exit 144). This has happene
## Before you touch the page
The page is markup and CSS in `web/index.html` and TypeScript in `web/src/`. `build.rs` runs
`web/build.mjs`, which uses swc to strip the types, put the script into the page and minify the
whole thing, and the result is `include_str!`d into the binary. So **every page change needs a
`web/build.mjs`, which uses swc to strip the types and minify the script into `app.js` (and
`login.js`), and minifies the page, and the results are `include_str!`d into the binary. The page
loads its script as `/app.js?v=<hash of its contents>`: the page is served `no-cache` and the
script `immutable`, so a browser keeps the script until a deploy changes it and its name. So **every page change needs a
rebuild** before it is visible, and building needs node and `npm ci` run once.
The files in `web/src` are not modules. They are one script split up, concatenated in the order