Skip to content

fix: prevent stale data when using the back button (fixes #12914) #13371

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rit3sh-x
Copy link

@rit3sh-x rit3sh-x commented Aug 5, 2025

The browser showed stale data when using the back button after making changes to the database. This happened because the browser's bfcache was restoring the previous state instead of fetching the updated data.

To solve this, I added a router.refresh() after the database update to force the page to reload and reflect the latest state. This is a reliable temporary fix, but I understand that it increases backend calls. I'm planning to improve this further by removing the refresh and implementing a more efficient, reactive solution.

Fixes #12914

@rit3sh-x rit3sh-x changed the title Fixes issue #12914 – Prevent stale data when using the back button in browser. fix: prevent stale data when using the back button (fixes #12914) Aug 5, 2025
@rit3sh-x
Copy link
Author

Any suggestions?

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a browser cache issue where stale data was displayed when using the back button after database updates. The fix adds a router.refresh() call to force the page to reload and reflect the latest state after successful form submissions.

  • Adds router.refresh() call after successful form submissions when no redirect is specified
  • Updates TypeScript type definitions to change ID types from number to string

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/ui/src/forms/Form/index.tsx Adds router refresh to invalidate client-side cache after form submission
test/_community/payload-types.ts Updates ID type definitions from number to string across all entity interfaces

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Refresh the screen always to reset the cache

Co-authored-by: Copilot <[email protected]>
@rit3sh-x
Copy link
Author

Is this correct now? or should I resolve it any other way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Back button loads outdated document after save
2 participants