perf(website): cache certificate images between deploys (~25 min → ~4 min) - #1281
Merged
Conversation
Groundwork for caching _site/c between CI deploys: images for certificates that are no longer issued are deleted after each render pass, so a restored cache can never ship a revoked credential. Unit tests cover the prune. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Restore website/.cache (digest manifest) and website/_site/c (rendered PNGs) before the build, per-run key with prefix restore, so only new or changed certificates re-render. Pairs with the pruneStaleImages pass so a restored cache can never ship a revoked credential. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before merging — one manual step
Neither of Felipe's stored tokens carries the
workflowscope, so this PR currently contains only the code half. The workflow edit below must be added from an account/token withworkflowscope (edit.github/workflows/website-deploy.ymlin the web UI on this branch, or push aftergh auth loginwith the workflow scope). Insert this step between "Fail if POSTHOG_KEY is missing" and "Build site":Why
Every website deploy takes 21–30 minutes (last four: 27.0, 26.7, 29.6, 21.2). Almost all of it is the certificate image renderer: two large satori+resvg canvases per issued certificate, re-drawn from scratch every deploy because neither the digest manifest (
website/.cache) nor the rendered PNGs (_site/c) survive between CI runs — only npm is cached.What
website/.cache+website/_site/cacross runs. Per-run key + prefix restore-keys, so the post-job save always records the newest state and the next run restores the most recent one.pruneStaleImagesinlib/certs/image-cache.mjs, called after each render pass. With_site/cnow persisted, images for certificates that are no longer issued would otherwise ride the cache forever; the prune deletes them. Correctness of content was already handled by the digest manifest (attendee data + renderer fingerprint), which is unchanged. The prune is safe to land before the workflow change (on a clean_siteit is a no-op).website/test/cert-image-prune.test.mjs(4 cases: stale pair deleted, current + non-PNG kept, dotted codes, missing dir no-op).Verified
npm test: 11/11 pass. Clean Eleventy build. Biome clean.Expected effect: website deploys drop from ~25 min to ~3–4 min when few certificates changed; a renderer/template change still re-renders everything (fingerprint in the digest), which is correct.
🤖 Generated with Claude Code