sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
17.81k stars 1.78k forks source link

svelte 5 : navigation hanging in prod with cached _data.json #12180

Open zhihengGet opened 2 weeks ago

zhihengGet commented 2 weeks ago

Describe the bug

everything works locally, but after deployment to cloudflare worker the navigation starts to hang.

if i am on page A, then navigate back to Page B by click on a link cause hanging.

i checked devtool, _data.json file is fetched with status 304 and no response cache-control but navigation does not happen , the response itself is also wrong, i.e /blog/1/_data.json would return the response for /blog/1 which is the response from my database

, the correct response is which i got from local dev: image

in local env, i see status for_data.json after click on link is 200and the response cache-control is no-store, so in production, i tried disable browser cache which solved the problem,

fixed it by adding a page rule to not cache _data.json path for cf i, but i feel like this is a bug with sveltekit , using cache is fine for _data.json i guess?

fixed it by adding reqeust cache controller header - no store by proxying fetch

if there's any other suggestions would be great..

Reproduction

if you really really really need one, i can try to come up with one but since it is on prod only , it will be a bit hard

Logs

No response

System Info

windows, svelte 5 RC, chrome latest version, kit latest

Severity

serious, but I can work around it

Additional Information

No response

davidlgj commented 1 week ago

@zhihengGet I'm having a similar issue, _data.json files are cached when I pushed a new release with adapter-static since they don't have a hash in the filename.

I'm curious why did you closed this issue? Did you find a solution?

zhihengGet commented 1 week ago

@zhihengGet I'm having a similar issue, _data.json files are cached when I pushed a new release with adapter-static since they don't have a hash in the filename.

I'm curious why you closed this as issue? Did you find a solution?

i think i did it by make sure fetch request has no-store in cache-control, you can refer here on how to handle fetch, https://github.com/sveltejs/kit/issues/9530 and you can also try adding a cache rule to make sure data.json never cache on cf