-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
stale data when client-side navigating after a new deployment #8697
Comments
I don't think there's anything we should do to fix this. If I remember @Rich-Harris correctly the idea is to give this into the hands of the user - it may not always be desireable to do a full page refresh even if the site is outdated, you may lose all your client side data unexpected. // +layout.svelte
import { beforeNavigate } from '$app/navigation';
import { updated } from '$app/stores';
beforeNavigate(({ willUnload, to }) => {
if ($updated && !willUnload && to?.route.url) {
location.href = to.route.url.href;
}
}); |
Thank you @s3812497 & @dummdidumm ! I tried this and it's not working yet, I tried this with @geoffrich suggestions (pollInterval & data-sveltekit-reload) & without and on every navigation post deploy +layout.svelte Thank you so much! |
Solved the issue in the above comment here: #8665 (reply in thread) Definitely think there's room to improve docs here -- "falling back to traditional full-page navigation if it detects that a new version has been deployed" sounds like Kit will do this automatically, and it doesn't seem like that's the case. Haven't tried out dummdidumm's solution, but I have an alternate approach conditionally applying |
Describe the bug
first brought up in #8665
SvelteKit does not correctly reload the page when navigating after a new app has been deployed.
It only reloads when an error has occurred, such as when a file cannot be found because its name has changed (rollup changes the filename hash when the page content has changed).
However, this will not occur if the user has already visited the page in that client-side navigation session.
It only occurs for the pages that haven't been visited yet.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-mxgjjq?view=editor
npm run build && node build
in the terminal.Open in New Tab
in the top-right corner to avoid StackBlitz's automatic reload.ctrl + c
into the terminal.src/routes/+page.svelte
.npm run build && node build
into the terminal again./
in the website.Expected
A native navigation to the home page and the version number at the bottom of the page changes.
Actual
The website still displays the old home page until you manually refresh the page.
Logs
No response
System Info
Severity
annoyance
Additional Information
https://kit.svelte.dev/docs/configuration#version
The text was updated successfully, but these errors were encountered: