Skip to content

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

@Fredkiss3

Description

@Fredkiss3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions