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

[NEXT-1161] Cached data is used after reloading immediately deployed app #48985

Open
1 task done
zartinn opened this issue Apr 29, 2023 · 5 comments
Open
1 task done
Labels
area: app App directory (appDir: true) Documentation Related to Next.js' official documentation. linear: next Confirmed issue that is tracked by the Next.js team. Pages Router Related to Pages Router.

Comments

@zartinn
Copy link

zartinn commented Apr 29, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.3.2-canary.13
      eslint-config-next: 13.3.1
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Data fetching (gS(S)P, getInitialProps)

Link to the code that reproduces this issue

https://github.com/zartinn/nextjs-vercel-cache-testing

To Reproduce

  1. Call deploy hook for provided github Repo (main branch)
    curl -X POST https://api.vercel.com/v1/integrations/deploy/prj_OJkGJqg01lu7a2xuu2hGtntmqb4m/96mk0aXWzW\?buildCache\=false
  2. wait 60s until build is done
  3. open deployed page: https://nextjs-vercel-cache-testing.vercel.app/
  4. reload page within a couple of seconds (when you wait more than a minute it works fine and no old cache is used)
    --> at second page load you should see an old value for the HTML

Describe the Bug

Prerequesites for error:

  • only with appDir (pages dir works fine)
  • only on Vercel (Heroku works fine)

Description

  • I have fetch some random data on build time.
  • This data is fetched on build time (SSG).
  • I previously deployed the app by calling a deploy hook without buildCache=false
  • It seems that now when I am calling a deploy hook with buildCache=false that the deployed app after the reload shows an old cache from an earlier deploy where I didn't used buildCache=false.
  • not using buildCache=false at all will not update the data at all btw (issue on its own?)

Really strange caching error. Even stranger is it that the reload must happen pretty quickly in order that the old cache show up. When I wait about a minute on the page and reload then (and all reloads afterwards) show the correct data.

Expected Behavior

Old weird cache should never be visible after reload

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

NEXT-1161

@zartinn zartinn added the bug Issue was opened via the bug report template. label Apr 29, 2023
@github-actions github-actions bot added area: app App directory (appDir: true) Pages Router Related to Pages Router. labels Apr 29, 2023
@zartinn
Copy link
Author

zartinn commented May 7, 2023

@timneutkens timneutkens added area: documentation linear: next Confirmed issue that is tracked by the Next.js team. labels May 17, 2023
@timneutkens timneutkens changed the title Cached data is used after reloading immediately deployed app [NEXT-1161] Cached data is used after reloading immediately deployed app May 17, 2023
@timneutkens timneutkens removed the bug Issue was opened via the bug report template. label May 17, 2023
@0xtimsb
Copy link
Contributor

0xtimsb commented May 31, 2023

This is happening. 10 days old stale data is being shown even after deploying. Even though revalidate time is 24 hours.

@webdevcody
Copy link

webdevcody commented Jul 26, 2023

We just ran into a similar bug where when we set the revalidate on the fetch method to 24 hours, nothing ever revalidates. We've had a page which displayed stale data even after 4 days.

const response = await fetch(url, {
      next: {
        revalidate: 86400
      },
    });

The moment we changed it down to 1 hour, everything revalidated after the new deployment.

@nativedone
Copy link

We just ran into a similar bug where when we set the revalidate on the fetch method to 24 hours, nothing ever revalidates. We've had a page which displayed stale data even after 4 days.

const response = await fetch(url, {
      next: {
        revalidate: 86400
      },
    });

The moment we changed it down to 1 hour, everything revalidated after the new deployment.

I've just tried this. By reducing the revalidate time to 1 hour does not resolve the issue for me.

When I refresh the page just after having deployed it, it still shows the stale data. My guess is that by reducing the revalidation time we are just reducing the waiting time the data needs to eventually be purged by Vercel infra.

I say that because I'm running another environment for the same project but setting the revalidation time to 3 sec. This one probably has the same issue but we do not perceive it because the waiting time is too short.

@timneutkens are you able to give some guidance on how to avoid this issue when setting long revalidate times?

@sarthaksaklecha
Copy link

is it only me or it's shocking how such a major framework has bugs in it's core functionalities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: app App directory (appDir: true) Documentation Related to Next.js' official documentation. 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

7 participants