Skip to content

fix(www): optimize blog author avatar loading - #1908

Merged
yamcodes merged 2 commits into
v1from
cursor/optimize-blog-author-avatars-d0dd
Sep 21, 2026
Merged

yamcodes merged 2 commits into
v1from
cursor/optimize-blog-author-avatars-d0dd

Conversation

@yamcodes

@yamcodes yamcodes commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

Blog author profile pictures were slow on every render because they:

  1. Pointed at github.com/{user}.png, which 302s to avatars.githubusercontent.com with Cache-Control: no-cache
  2. Used next/image with unoptimized, so Next never cached or resized them

Changes

  • Serve avatars from avatars.githubusercontent.com/{handle}?s={size} (direct 200, no redirect)
  • Enable Next.js image optimization (drop unoptimized)
  • Add sizes / preload on post avatars (Next.js 16; not deprecated priority)
  • Allowlist only avatars.githubusercontent.com in images.remotePatterns

Review follow-ups

  • Swapped prioritypreload
  • Removed site-wide minimumCacheTTL: 31 days (risky for local /assets/*)
  • Dropped unused github.com remote pattern

Test plan

  • Unit test for getAuthorAvatarUrl
  • Load /blog and a post; confirm avatars come from /_next/image?...
  • Confirm PFPs render at the expected sizes
  • Optimized 32w variant ~1.9KB / ~3ms cache HIT vs ~60–190ms GitHub redirect path
Open in Web Open in Cursor 

Serve avatars from avatars.githubusercontent.com (no redirect), enable
next/image optimization instead of unoptimized, and raise remote image
cache TTL so PFPs do not cold-fetch on every render.

Co-authored-by: Yam Borodetsky <hi@yam.codes>
@changeset-bot

changeset-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4910e78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added www Improvements or additions to arkenv.js.org tests This issue or PR is about adding, removing or changing tests labels Sep 21, 2026
@yamcodes yamcodes added the bug Something isn't working label Sep 21, 2026 — with Cursor
@yamcodes yamcodes added the preview Opt-in gate for PR preview deployments label Sep 21, 2026
@arkenv-bot

arkenv-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (Asia/Almaty)
arkenv Ready Ready Preview, Comment Sep 21 2026, 11:11 AM (Asia/Almaty)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

  • Avatar host swapgetAuthorAvatarUrl now targets avatars.githubusercontent.com/{handle}?s={size} instead of github.com/{handle}.png, verified to return 200 directly rather than a no-cache 302, with the JSDoc updated to match.
  • Blog index avatar — drops unoptimized and adds sizes="20px" so Next optimizes and caches the 20px thumbnail.
  • Blog post avatar — drops unoptimized, adds sizes="32px" and priority on both the linked and unlinked variants.
  • images.minimumCacheTTL — raised to 31 days (2678400s) in next.config.ts; remotePatterns already allowed both hosts, so no pattern change was needed.
  • Unit test — expected URL in blog-author.test.ts updated to the new host/query format.

ℹ️ Nitpicks

  • The github.com entry in images.remotePatterns is now unused by next/image — only the two blog call sites referenced github.com/{user}.png, and both now use avatars.githubusercontent.com. Dropping it would tighten the allowlist.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread apps/www/app/(home)/blog/[slug]/page.tsx Outdated
Comment thread apps/www/next.config.ts Outdated
Use next/image `preload` instead of deprecated `priority`, drop the
site-wide 31-day minimumCacheTTL, and remove the unused github.com
remotePatterns entry.

Co-authored-by: Yam Borodetsky <hi@yam.codes>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Addressed prior feedback — commit 4910e78 responds to all three prior findings: both post-avatar priority props swapped to preload, the site-wide minimumCacheTTL: 31 days removed, and the now-unused github.com remotePatterns entry dropped.
  • preload is the correct Next 16 API — verified against the pinned next@16.2.6; priority is marked deprecated in favor of preload in get-img-props.d.ts, and both [slug]/page.tsx variants (:79, :90) now use it. Only one renders per request, so there is no double-preload.
  • github.com removal is safe — the only remaining github.com references in apps/www are link hrefs (header/star buttons, author profile link), not next/image sources, so tightening the allowlist to avatars.githubusercontent.com breaks nothing.
  • Cache behavior — dropping minimumCacheTTL returns optimized images to Next's default TTL, which avoids masking in-place replacements of local /assets/* files while still caching the avatars.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@yamcodes
yamcodes merged commit a86c916 into v1 Sep 21, 2026
17 checks passed
@yamcodes
yamcodes deleted the cursor/optimize-blog-author-avatars-d0dd branch September 21, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working preview Opt-in gate for PR preview deployments tests This issue or PR is about adding, removing or changing tests www Improvements or additions to arkenv.js.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants