sveltejs / kit

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

etags for `__data.json` requests #10348

Open MrGerbeck opened 11 months ago

MrGerbeck commented 11 months ago

Describe the problem

A few issues exposed by a dashboard with loads 2mb of data on a particular page.

I've debated call this a "bug" because I feel that SvelteKit, with all its clever tricks, should be better than the default behavior. Back button should not be slower than a page reload. It isn't expected behavior that going back to a page should yield different results. And even so, eTags are prevent data from being sent not re-computation. And middleware outside of SvelteKit shouldn't be necessary.

Describe the proposed solution

Some suggestions:

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

MrGerbeck commented 11 months ago

Currently, support for Etags can be achieved either through the use of hooks or through a custom server that wraps the app. There is no way to set a page to always SSR even on the back-button action, at least, as far as I am awaer.

dummdidumm commented 11 months ago

I think the "always SSR" request is handled in some other issue, so I reworded the issue title to ask for etags support on __data.json requests.

zzolo commented 1 month ago

I think being able to set any headers on this request would be extremely helpful. The fact that it specifically sets 'cache-control': 'private, no-store' means that any benefits from caching from a browser or CDN or similar are non-existent and so client-side routing is actually worse than regular browsing. I'm sure there was a reason for this design choice, but it seems really harmful and I would love to see an easy way to override this behavior.

Similarly, what are the ways with hooks or middleware to get around this?