Make the site faster to load and lighter on the server

- Every page but Home, and the whole admin, loads on first visit: the
  main bundle drops from 579 kB to 314 kB (173 to 98 kB gzipped); a
  tab on an old build reloads once when a page chunk has gone
- Home asks for events and the timeline alongside its own data, and
  the server preloads /api/front-page and the first hero photo
- Hero headline rises in as one piece (it held back the page's
  largest paint), sized to stay within two lines; min-h in dvh; first
  slide fetched at high priority
- Every raster upload gets a 640px copy (at upload, and at boot for
  older files); logos, avatars and card pictures load it and fall
  back to the full file
- Login password checks run off the event loop; only admin requests
  are logged per request; ffmpeg runs at nice 19 on Linux
- Page HTML is no-cache, so a deploy can't strand a cached page on
  missing assets; source maps are no longer linked
- Migration 042: index person_awards by award
- docs/performance.md, and gzip and HTTP/2 for nginx

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 02:41:45 -05:00
parent be7e92417e
commit f72a9604d2
23 changed files with 420 additions and 139 deletions

View file

@ -35,7 +35,7 @@ import adminEntities from "./routes/admin-entities.js";
import media from "./routes/media.js";
import clips from "./routes/clips.js";
import { CLIPS_DIR, startClipWorker } from "./clips.js";
import { UPLOADS_DIR } from "./media.js";
import { UPLOADS_DIR, writeMissingThumbs } from "./media.js";
import { logSafe, startSessionSweeper } from "./auth.js";
import { syncDescriptorsWithSchema } from "./admin-schema-sync.js";
import { ENTITIES } from "./admin-schema.js";
@ -53,12 +53,20 @@ syncDescriptorsWithSchema(db, ENTITIES);
console.log(`db ${DB_PATH} (${db.driverName}, schema v${version})`);
await mkdir(UPLOADS_DIR, { recursive: true });
console.log(`uploads ${UPLOADS_DIR}`);
// In the background: pages fall back to the full file until it's done.
writeMissingThumbs()
.then((made) => made && console.log(`uploads: made ${made} small copies`))
.catch((err) => console.warn(`uploads: small copies failed: ${err.message}`));
/* ── App ─────────────────────────────────────────────────────── */
const app = new Hono();
app.use("*", logger());
// One log line per admin request, for the record of who did what.
// Public traffic is left to nginx's access log: logging every request
// here too would double the lines and, under a spike, cost the event
// loop a synchronous write each.
app.use("/api/admin/*", logger());
/* Headers for every response. Referrer kept to the origin (YouTube
embeds refuse to play without one). No HSTS here: nginx sends it on