Famous people: a page without its portrait is not cached; the admin list refreshes
CI / test (push) Successful in 1m57s
CI / build (push) Skipped
CI / deploy (push) Skipped

The worker does not clear the page cache when the portrait is done, so a
page loaded right after publishing showed "hamarosan elkészül" for five
minutes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-22 16:59:07 +00:00
co-authored by Claude Opus 5.5
parent 37cb0abf4b
commit 2997a06474
2 changed files with 18 additions and 3 deletions
+8 -1
View File
@@ -24,7 +24,14 @@ export const loadCelebrity = cache(async (slug: string): Promise<PublicCelebrity
const res = await fetch(`${BACKEND_URL}/v1/public/celebrities/${slug}`, {
next: { revalidate: 300, tags: [CELEBRITIES_TAG] },
});
if (res.ok) return (await res.json()) as PublicCelebrity;
if (res.ok) {
const c = (await res.json()) as PublicCelebrity;
if (c.analysis) return c;
// The portrait is still being written (the worker does not clear the
// cache when it is done): no cached copy until it is there.
const fresh = await fetch(`${BACKEND_URL}/v1/public/celebrities/${slug}`, { cache: "no-store" });
return fresh.ok ? ((await fresh.json()) as PublicCelebrity) : c;
}
if (res.status !== 404) throw new Error(`celebrity ${slug}: HTTP ${res.status}`);
const token = (await cookies()).get(SESSION_COOKIE)?.value;
if (!token) return null;