Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch cache seeded at build time during SSG is not reused at runtime on Vercel #62649

Open
Fredkiss3 opened this issue Feb 28, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Pages Router Related to Pages Router.

Comments

@Fredkiss3
Copy link
Contributor

Fredkiss3 commented Feb 28, 2024

Link to the code that reproduces this issue

https://github.com/Fredkiss3/inconsistent-fetch-cache-during-build-and-start

To Reproduce

  1. Import the project on vercel
  2. Watch the build logs, it should give you the same logs for every page as they are SSG'ed (which means the data is cached)
{
  'LAYOUT FETCH': {
    unixtime: 1708398669,
    utc_datetime: '2024-02-20T03:11:09.078181+00:00'
  }
}
  1. When the build has finished, go to /u/5
  2. You will notice that the data shown is different than the data shown at build time
  3. If you go to /u/3 it will show a different value (the same that is shown at build time)

Current vs. Expected behavior

Following the previous steps, I expected to have the same values shown at build time and at runtime, meaning that the fetch cache is set and reused at runtime but it doesn't.

If you try building the project locally, you will notice that the data is effectively cached at build time and the same data is reused at runtime. This may be because when running locally nextjs use the folder .next/cache/fetch-cache and is correctly seeded at build time, On vercel it isn't considered.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: N/A
  pnpm: 8.15.3
Relevant Packages:
  next: 14.1.0
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, Data fetching (gS(S)P, getInitialProps)

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

The site is deployed on Vercel.

Also If you have access to Vercel Request metrics, you will notice that the first call to the fetch cache shows a CACHE MISS and next requests reuse the cached data :

First Request

image

Second Request

image

NEXT-3291

@Fredkiss3 Fredkiss3 added the bug Issue was opened via the bug report template. label Feb 28, 2024
@github-actions github-actions bot added the Pages Router Related to Pages Router. label Feb 28, 2024
@perhp
Copy link

perhp commented Apr 16, 2024

@Fredkiss3 Did you find any ways to fix this? I have the exact same problem on my production site. 😄 I'm on version 14.2.1, so it doesn't seem to have been fixed yet.

@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Pages Router Related to Pages Router.
Projects
None yet
Development

No branches or pull requests

2 participants