Skip to content

Make the Replicate page fast - #151

Merged
skyfallwastaken merged 1 commit into
neofrom
replicate-perf
Sep 26, 2026
Merged

skyfallwastaken merged 1 commit into
neofrom
replicate-perf

Conversation

@skyfallwastaken

Copy link
Copy Markdown
Member

The Replicate page was slow for three reasons, each fixed here:

  1. 22.7 MB of cover images. Cards loaded Replicate's original covers, several of them 2–6 MB PNGs and GIFs. Covers are now served from /replicate/covers/<owner>/<name> as 640 px WebP thumbnails, made with Bun.Image and cached in memory per source URL for a day. When a cover can't be re-encoded (GIF, video, fetch failure), the endpoint redirects to the original. Only covers of listed models are served, so it isn't an open proxy.
  2. Full model objects in the page data. Each card shipped Replicate's whole model object, including default_example and the OpenAPI schema. The page now gets only the fields a card renders.
  3. Slow first visit after a deploy. The catalog was built on the first visit, which took 2–7 s (one model fetch and one pricing fetch per model). backend.start() now warms the catalog and the cover thumbnails in the background, which covers both entrypoints.

Also fixed along the way: the aspect-video cover box grew to the image's own height, so rows were uneven. The image is now absolutely positioned inside the box.

Numbers

Local dev server, 29 cards, scrolled to the bottom:

Before (neo) After
Images transferred 22.69 MB 0.58 MB
Page HTML 343 KB 168 KB
Page data, first request after a cold start 1.69 s (6.6 s on an earlier run) 0.02 s
A cover, first request after start original from Replicate's CDN ~5 ms, 7–50 KB

Screenshots

Before (neo): uneven cover heights After
before after

Testing

  • read-model.test.ts:
    • cards carry only card fields;
    • a 1600×900 PNG cover comes back as a 640×360 WebP;
    • a cover that can't be decoded redirects to the original;
    • an unlisted model gets no cover.
  • bun run typecheck, bun run check: 0 errors. bun test: 0 fail.

🤖 Generated with Claude Code

@skyfallwastaken
skyfallwastaken merged commit b2f4e5c into neo Sep 26, 2026
3 checks passed
@skyfallwastaken
skyfallwastaken deleted the replicate-perf branch September 26, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant