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

Link with prefetch={false} is not respected in the latest canary #48780

Closed
1 task done
Fredkiss3 opened this issue Apr 24, 2023 · 4 comments
Closed
1 task done

Link with prefetch={false} is not respected in the latest canary #48780

Fredkiss3 opened this issue Apr 24, 2023 · 4 comments
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@Fredkiss3
Copy link
Contributor

Verify canary release

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

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: Ubuntu 20.04.0 LTS Mon Apr 24 2023 16:37:30 GMT+0200 (heure d’été d’Europe centrale)
    Binaries:
      Node: 16.14.2
      npm: 7.17.0
      Yarn: 1.22.19
      pnpm: 8.2.0
    Relevant packages:
      next: 13.3.2-canary.2
      eslint-config-next: N/A
      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), Routing (next/router, next/navigation, next/link)

Link to the code that reproduces this issue

https://stackblitz.com/github/Fredkiss3/next-dynamic-test-updated?file=app%2Flayout.tsx

To Reproduce

  1. Click on the link above
  2. Go to /dynamic (either by clicking on the link or by clicking on the button)
  3. You will see on the console the current time
  4. Try navigating to another page, then navigate again to /dynamic, this time you won't see anything printed on the console
  5. If you wait 30+ seconds, and navigate again to /dynamic you will see the current time logged in the terminal

Describe the Bug

There were some improvements about route segment caching on client navigations introduced by this PR #48383 , but with that now <Link prefetch={false}> is not respected anymore even though it is said that a link without prefetching should not be cached at all and always refetched between navigations, this is a bug because there are some cases where we want always fresh data like auth gated routes with JWT sessions limited in time, and more.

Expected Behavior

When using a Link with prefetch={false} the page should not be cached at all and all subsequent navigations should refetch and call the server.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@Fredkiss3 Fredkiss3 added the bug Issue was opened via the bug report template. label Apr 24, 2023
@github-actions github-actions bot added area: app App directory (appDir: true) Navigation Related to Next.js linking (e.g., <Link>) and navigation. labels Apr 24, 2023
@Fredkiss3
Copy link
Contributor Author

Fredkiss3 commented May 9, 2023

Closing as it is how it's supposed to work.

@Fredkiss3 Fredkiss3 closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2023
@karlhorky
Copy link
Contributor

Closing as it how it is supposed to work.

@Fredkiss3 can you elaborate here? It is desired, expected behavior that Links using prefetch={false} will see caching behavior? I guess this is the same caching behavior as a normal Link?

Also, where did you get this information?

@Fredkiss3
Copy link
Contributor Author

Fredkiss3 commented May 9, 2023

  • Yes, prefetch={false} disable prefetching, but not caching
  • I asked a core member of the team who worked on the PR (feedthejim) and he confirmed that
  • I would have preferred for it to not also cache, but it is how it's supposed to work

For pages that do not need caching, it seems like there will be a way to specify for how long a page should be cached on the client, It is said in the PR :

Follow ups

  • we may add another API to control the cache TTL at the page level

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

2 participants