diff options
| author | Adam Soltys <[email protected]> | 2026-12-03 21:54:36 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-12-03 21:54:36 -0700 |
| commit | cede049f15c9bdcf3991656070c3067d8f152753 (patch) | |
| tree | 4e5b59b5fd6920741481509aa6cf96c1d7cafca1 /feed/profile-page.js | |
| parent | 9f55be849bbac1aa5071fa5a93289fda6fe08e08 (diff) | |
| download | coinosv3-cede049f15c9bdcf3991656070c3067d8f152753.tar.gz coinosv3-cede049f15c9bdcf3991656070c3067d8f152753.zip | |
feed: a link-preview crawler waits up to 6 s for a post's page, so the shared card shows the post.
"can we add some meta tags that would show a better title/description/content preview for posts when i link to them on social media?" (Adam, 2026-12-04, with a Telegram card for his fresh nevent link showing the generic Coinos card). The post pages already carry the author as og:title, the text as og:description and the post's picture or the author's face as og:image, but a post the server hadn't cached got 500 ms (profiles 2 s) before the plain page went out, and a post shared right after it was written misses that: Telegram fetched it once and kept the site's card. Link-preview crawlers (Telegram, X, Facebook, WhatsApp, Slack, Discord, LinkedIn, Mastodon & co, search bots: isPreviewBot) now get up to 6 s; people keep the short wait.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar (feed copy, same as coinosv3-server)
Diffstat (limited to 'feed/profile-page.js')
| -rw-r--r-- | feed/profile-page.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/feed/profile-page.js b/feed/profile-page.js index 623dc09..22a8370 100644 --- a/feed/profile-page.js +++ b/feed/profile-page.js @@ -11,7 +11,7 @@ // page goes out (and the build carries on into the cache). import { decode } from 'nostr-tools/nip19'; import { verifyEvent } from 'nostr-tools/pure'; -import { NOTE_RELAYS, esc, scriptJson, siteTagsOut, siteImage } from './note-page.js'; +import { NOTE_RELAYS, esc, scriptJson, siteTagsOut, siteImage, isPreviewBot, BOT_BUDGET_MS } from './note-page.js'; export const PROFILE_PATH = /^\/((?:npub1|nprofile1)[a-z0-9]+|[A-Za-z0-9._-]{1,30})\/?$/; // single-segment app routes and files that are never a person @@ -207,7 +207,7 @@ export async function profilePageResponse(req, { index, profiles, resolveName }) if (!ref.pk) ref.pk = await resolveName(ref.name); if (!ref.pk) return new Response(html, { headers }); ref.id = ref.pk; // the cache's key - const data = await profiles.get(ref, PROFILE_BUDGET_MS).catch(() => null); + const data = await profiles.get(ref, isPreviewBot(req.headers.get('user-agent')) ? BOT_BUDGET_MS : PROFILE_BUDGET_MS).catch(() => null); const proto = req.headers.get('x-forwarded-proto') || 'https'; const host = req.headers.get('x-forwarded-host') || req.headers.get('host'); return new Response(data ? renderProfilePage(html, data, ref, host ? proto + '://' + host : '') : html, { headers }); |
