Famous people: a page without its portrait is not cached; the admin list refreshes
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user