From b4969c29ef308239696f24beede25be169bdc57c Mon Sep 17 00:00:00 2001 From: Kai Chen Date: Fri, 8 May 2026 02:24:40 -0700 Subject: [PATCH] fix: refresh substack feed every 10m and drop dead feed url The homepage Blog card was showing stale posts for up to an hour after publishing because the RSS fetch was cached with `revalidate: 3600`. Drop that to 600s (10 min) so new posts surface quickly. Also remove `https://substack.com/@/feed` from FEEDS; Substack now serves the generic discover page (HTTP 404) at that URL, so every refresh was paying for a dead request before falling through to the publication feed. Co-authored-by: Claude Co-authored-by: Cursor --- app/lib/substack.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/lib/substack.ts b/app/lib/substack.ts index f745095..4398f54 100644 --- a/app/lib/substack.ts +++ b/app/lib/substack.ts @@ -5,10 +5,13 @@ export type SubstackPost = { description: string; }; -const FEEDS = [ - "https://substack.com/@kaiiiichen/feed", - "https://kaiiiichen.substack.com/feed", -]; +// `https://substack.com/@/feed` started returning 404 (it serves the +// generic discover HTML page now), so we hit the publication feed directly. +const FEEDS = ["https://kaiiiichen.substack.com/feed"]; + +// Refetch the RSS feed every 10 minutes so newly-published posts appear on the +// homepage within ~10 min instead of the previous 1 h window. +const REVALIDATE_SECONDS = 600; function extractTag(xml: string, tag: string): string { const cdataMatch = new RegExp(`<${tag}[^>]*><\\/${tag}>`, "i").exec(xml); @@ -34,7 +37,7 @@ export async function getSubstackPosts(): Promise { for (const feed of FEEDS) { try { const res = await fetch(feed, { - next: { revalidate: 3600 }, + next: { revalidate: REVALIDATE_SECONDS }, headers: { "User-Agent": "kaichen.dev/1.0" }, }); if (!res.ok) continue;