-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Respect Cache-Control of serialized SSR fetch responses during subsequent client-side navigation #4625
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
Labels
breaking change
feature / enhancement
New feature or request
p3-edge-case
SvelteKit cannot be used in an uncommon way
Milestone
Comments
If possible, we should also ensure that any |
I'm not sure if the added complexity of implementing this is worth it |
dummdidumm
added a commit
that referenced
this issue
Aug 31, 2022
...for initially fetched responses Closes #4625 The proposed etag logic is not implemented because it sounds too complex and would add needless code for 99% of users This is a breaking change insofar that people could have relied on the old behavior somehow
5 tasks
Rich-Harris
added a commit
that referenced
this issue
Sep 1, 2022
* [breaking] respect cache-control max-age on the client ...for initially fetched responses Closes #4625 The proposed etag logic is not implemented because it sounds too complex and would add needless code for 99% of users This is a breaking change insofar that people could have relied on the old behavior somehow * calculate ttl on the server * oops * oops * no * invalidate cache on POST * fix * simplify * deflake, hopefully * try to make test less flaky * disable when prerendering Co-authored-by: Rich Harris <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking change
feature / enhancement
New feature or request
p3-edge-case
SvelteKit cannot be used in an uncommon way
Describe the problem
The fetch responses that are serialized as part of the SSR response are currently only used during the initial hydration of the app. If the same URLs are requested during subsequent client-side navigation, these requests are performed (at least) once more, regardless of the Cache-Control headers in the responses.
Describe the proposed solution
It would be nice if, even after the initial view is hydrated, the
fetch
function that's passed toload
still checked with the serialized responses to see whether any of them are still valid. We should already have the information we need to make this decision, because the response headers for all of these requests are also serialized into the server-rendered HTML.Alternatives considered
No response
Importance
would make my life easier
Additional Information
I have a fairly large chunk of data I want to expose throughout my app. When I request it in the root
__layout
load
and expose it throughstuff
, this results in the data being requested again after navigating, regardless of theCache-Control
header in the response.Currently, my workaround is to fetch the data during the
handle
hook and expose it throughsession
. From here, the root__layout
can then still expose it to the rest of the app withstuff
without requiring widespread code changes.The text was updated successfully, but these errors were encountered: