Next.js Discord

Discord Forum

304 Not Modified (with repro)

Unanswered
West African Lion posted this in #help-forum
Open in Discord
Avatar
West African LionOP
I have bootstrapped a simple next app (create-next-app) and changed the app/page.tsx file to:
export const revalidate = 10;

export default async function LandingPage() {
  const number = Math.random();

  console.log("number", number);

  return <p>{number}</p>;
}


Repro here: https://github.com/akd-io/bug-304

When I then run next build and next start and visit the page, I get a random number.

When I spam-refresh the page, I see a new number written by the next start process. Perfect, revalidate works!

My problem is, no matter how much I refresh the page, I never see a new number in the browser.

All my requests to the Next.js server come back with these headers:
HTTP/1.1 304 Not Modified
Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
x-nextjs-cache: STALE
X-Powered-By: Next.js
Cache-Control: s-maxage=10, stale-while-revalidate
ETag: "16enogy3wx63ka"
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Date: Mon, 23 Oct 2023 15:05:20 GMT
Connection: keep-alive
Keep-Alive: timeout=5


If I do a hard refresh, the content is still shown, but this is because no new content ever comes from the server. I know this because opening the page in an incognito tab shows Chrome's default incognito tab page indefinitely.

2 Replies

Avatar
West African LionOP
Avatar
Aleutian Tern
Just to anyone facing the issue: Downgrading the Nextjs to <= 13.4.19 fix the issue.