Skip to content

Stale data after navigation when using internal API and SSR (app router) #69979

Description

@sidletski

Link to the code that reproduces this issue

https://github.com/sidletski/next-cache-issues

To Reproduce

  1. Clone the example project
  2. Install dependencies and run the development server (:3000 port)
  3. Navigate to the main page, which displays a list of users fetched from the internal API
  4. Click on the "Edit user" button for a specific user to go to the edit page
  5. Make changes to the user's information and submit the form
  6. Click the "Go back" button to return to the main page
  7. Observe that the user list on the main page is not updated with the new data
  8. Click the "Edit user" button again for the same user (or use browser back button)
  9. Notice that the edit form displays the old, unedited data
  10. Refresh the page manually (e.g., F5, Cmd+R or browser refresh button)
  11. Observe that only after a force reload, the updated data appears

Current vs. Expected behavior

After editing a user and navigating back using the "Go back" button (which uses next/link) or the browser's back button, the main page shows stale data, but I want the list to reflect the updated data
unstable_ functions from the next/cache package doesn't help :(

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 18.17.0
  npm: 9.6.7
  Yarn: 1.22.19
  pnpm: 8.15.7
Relevant Packages:
  next: 14.2.9 // Latest available version is detected (14.2.9).
  eslint-config-next: 14.2.9
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.2
Next.js Config:
  output: N/A

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

Navigation, Pages Router

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

next dev (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

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.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions