Repository navigation
Description
Problem
Link previews are cached forever. LinkPreview rows are shared by URL (CreateCommit::linkPreviewFor() uses firstOrCreate on sha256($url)), and UnfurlLink returns early once fetched_at is set. There is no TTL, no refresh action, and no way to update a preview when the linked page changes its title, description, or image.
This is visible today: https://mybox.id now serves:
Personal digital box: a browser-based suite of small apps — radio, tasks, pomodoro, notes and everyday tools. Works on any device.
but dev-null still renders the old description on every commit that links to it:
MyBox, something that you open everyday.
Affected public examples:
- https://dev-null.sh/@sonyarianto/commits/01a14862-ca9c-7335-9be1-e314e3082abe
- https://dev-null.sh/@sonyarianto/commits/01a14cc2-7a7c-730e-a204-b977ee565844
- https://dev-null.sh/@sonyarianto/commits/01a14f1e-ea45-73f2-b28a-501fb711280e
The first commit predates the site's metadata change; the later commits reuse the same cached row. Because previews are shared, one stale URL affects every post that links to it.
Possible directions
- TTL refresh (preferred): re-unfurl previews older than a bounded age (for example, 7 or 30 days) in the background. Keep the last successful metadata if a refresh fails, respect the existing SSRF and retry rules in
UpdateLinkPreview, and cap/batch the work so a sweep cannot flood the queue. - Manual refresh: a small refresh control on the card, throttled and limited to the commit author or admins. Since the row is shared, refreshing one card would update every card for that URL.
- Operations fallback: an admin-only way to clear or refetch a URL, even if automated refresh is not desired.
Implementation notes
fetched_atis already indexed.UnfurlLinkcurrently skips rows withfetched_at !== null; a refresh path needs to bypass or reset that guard without exposing a pending skeleton to all viewers.- A manual endpoint would need authorization and throttling; the existing link-preview endpoint is read-only and
private, no-store. - Tests should cover stale selection, successful refresh, failed refresh retaining old metadata, and no duplicate jobs for concurrent posts.
Question
Which direction fits the project? A TTL sweep seems least intrusive, but it changes when old cards update without user action. A manual refresh is more explicit but adds UI and an abuse surface.
Happy to open a PR for whichever direction you prefer.
Activity
[-]fix: refresh link previews when a page metadata changes[/-][+]fix: refresh link previews when a page's metadata changes[/+]fix: fetch link previews again once they are a week old