From 76bf401ee97ca50d9bd2bc3f21a50f484ca786db Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 27 Jul 2026 15:07:47 -0400 Subject: [PATCH] fix: revalidate blog 404s instead of pinning them for a year An empty query response is indistinguishable from a genuinely missing post, so returning notFound without revalidate lets Next cache a transient upstream failure at s-maxage=31536000. --- src/pages/blog/[slug].jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/blog/[slug].jsx b/src/pages/blog/[slug].jsx index d4bf114..cdfde1b 100644 --- a/src/pages/blog/[slug].jsx +++ b/src/pages/blog/[slug].jsx @@ -108,8 +108,14 @@ export async function getStaticProps(context) { revalidate: 3_600, }); + /** + * An empty response is not proof the post is gone. A failed query returns + * the same shape, so a `notFound` without `revalidate` pins a one year + * `s-maxage` on what may be a transient upstream failure. Re-check on a + * short interval instead. + */ if (!props?.props?.data?.post) { - return { props: {}, notFound: true }; + return { notFound: true, revalidate: 300 }; } return props;