vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.68k stars 26.84k forks source link

NextJS Caching based on Get URL and not Tag #63892

Open Arinji2 opened 6 months ago

Arinji2 commented 6 months ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/intelligent-fast-wtnw2x?file=%2Fapp%2Fpage.tsx%3A21%2C21

To Reproduce

  1. Access the site through dev or prod, both show the same issue

  2. Click on either of the dog revalidate buttons.

Current vs. Expected behavior

Current Behavior:

If you revalidate the cat image, it updates correctly. However revalidating either of the dog revalidate buttons causes both images to update even though they have a different tag setup but fetch the same url.

Expected Behaviour

If you revalidate either of the dog images, only they should update and not the other image. Since both have different tags, revalidating dog1 should update the fetch with the tag of dog1 and not the fetch with the tag of dog2, irrespective of fetch url's

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 8.15.4
Relevant Packages:
  next: 14.1.4
  eslint-config-next: 14.1.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.3
Next.js Config:
  output: N/A

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

App Router

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

next dev (local), next start (local)

Additional context

We tested it out on the NextJS Discord Server https://discord.com/channels/752553802359505017/752647196419031042/1223523452141441135

After it was brought up in one of the help forums on the Discord Server https://discord.com/channels/752553802359505017/1223347566863843430/1223510528429658203

steve-marmalade commented 6 months ago

Based on the description, this Issue might be relevant: https://github.com/vercel/next.js/issues/63509 . What's interesting is that in 63509, all tags on the page were revalidating, even though they had different URLs.

FWIW your codesandbox link shows me the following error image

Arinji2 commented 6 months ago

@steve-marmalade Yea thats a thing with codesandbox when you leave the dev server open for too long, i will delete the dev server so it dosent show that error

Also yea that issue looks similar, i will investigate both and see why there is a difference in both of ours results