Open MrGerbeck opened 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.
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.
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?
Describe the problem
A few issues exposed by a dashboard with loads 2mb of data on a particular page.
__data.json
and doesn't do Conditional Requests / send eTags. 2mb. Every. Time.data-sveltekit-reload
on links to the page and those are fast but the back-button is still slow by default (without the middleware)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:
__data.json
routes. If the data computes to the same hash, why send it again? Even with theinvalidation
flag, if nothing is changed there is zero reason to send all the data again. eTags aren't about saving computation but data transfer.Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response