Skip to content

perf: serve a static share card for people not on DevTrack - #3641

Merged
Priyanshu-byte-coder merged 2 commits into
mainfrom
perf/static-guest-share-card
Nov 18, 2026
Merged

Priyanshu-byte-coder merged 2 commits into
mainfrom
perf/static-guest-share-card

Conversation

@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

Summary

The share card at /u/<login>/opengraph-image now redirects people who aren't on DevTrack to a static copy of the existing Not ranked yet brand card (public/og/devtrack-card.png). Members keep their live rank card.

Why

Scrapers walk the ~1,300 guest profiles linked from the /top boards and fetch each one's share card exactly once, so the CDN cache never got a second hit. Every fetch looked the person up on GitHub, read the whole all-time leaderboard to estimate a rank, and drew a fresh PNG, all billed as Active CPU. On 2026-11-17 a scraper on Facebook's network did this about every two seconds and pushed the day past 15 minutes of the 4-hour monthly Hobby allowance. That network is now blocked in the firewall, but the next scraper would hit the same path.

A static file is served by the CDN with no function work. The redirect itself is cached for a day.

Trade-off

A link preview of a non-member's profile shows the generic brand card instead of an estimated rank. Very few people share a non-member's page; members' previews are unchanged. The redirect is temporary (307), so someone who joins gets their own card once the cached redirect expires.

Tests

  • test/og-user-image-route.test.ts: a guest gets a 307 to the static card with a day of CDN caching; a member still gets a PNG.
  • Type check and lint clean.

Deploy note: hold until after the 2026-11-19 Active CPU reading, so the firewall's effect is measured on its own.

Scrapers walk the ~1,300 guest profiles linked from the /top boards and
fetch each one's share card once, so the CDN never helped: every fetch
looked the person up on GitHub, read the whole leaderboard and drew a
fresh PNG. On 2026-11-17 one scraper did this every couple of seconds and
pushed Active CPU past 15 minutes for the day.

Guests now get a redirect to the existing "Not ranked yet" brand card as
a static file. Members keep their live card.
@github-actions github-actions Bot added type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts) labels Nov 18, 2026
@Priyanshu-byte-coder
Priyanshu-byte-coder merged commit c429da6 into main Nov 18, 2026
13 checks passed
@Priyanshu-byte-coder
Priyanshu-byte-coder deleted the perf/static-guest-share-card branch November 18, 2026 20:36
@github-actions

Copy link
Copy Markdown

🎉 Merged! Thanks for contributing to DevTrack.

If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers.

Keep an eye on open issues for your next contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant