Description
Describe the bug
Set up: Visit a page with client side navigation, where the destination +page.svelte
file is in the same directory as a +server.js
GET request handler, and a +page.js
universal load function.
Then duplicate the tab.
Expected: An identical HTML page is rendered in the new browser tab.
Actual: The JSON response from the +server.js
is rendered.
This also happens when using back/forwards browser navigation
Reproduction
Minimal repo:
https://github.com/oscarhermoso/bug-sveltekit-duplicate-tab/tree/main
Recording:
Logs
N/A
System Info
npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
System:
OS: Linux 6.2 Pop!_OS 22.04 LTS
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 4.62 GB / 15.56 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
Browsers:
Chrome: 112.0.5615.165
Chromium: 112.0.5615.49
Firefox: 112.0.1
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.0.1
@sveltejs/kit: ^1.5.0 => 1.15.9
svelte: ^3.54.0 => 3.58.0
vite: ^4.3.0 => 4.3.3
Severity
annoyance
Additional Information
This isn't related to any recent Sveltekit version - I am able to reproduce on Sveltekit 1.0.
It seems to be because of browser caching of the fetch request made on client load, because I can work-around the issue by adding Cache-Control headers to the GET request handler
setHeaders({
'Cache-Control': 'No-Store',
});
No response