-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix browser caching of endpoints instead of page #9780
Comments
This sounds like the expected - if unfortunate in this case - behavior to me. Browsers seem to cache fairly aggressively when duplicating tabs. If the request does make it to SvelteKit, then it will render either the page or endpoint according to the |
@Conduitry - Very nice, the |
It does seem useful, but I can't decide how I feel about quietly mutating the |
I think it makes perfect sense for the For example, Django REST Framework does this for their REST API - which has a friendly HTML interface when viewed in the browser. If the header was included in Sveltekit responses, we might need to address this block too: |
It makes sense to add it in when content-negotiation is happening. It'll be good to document it as well so that it can be opt-out / overridden / removed ? |
- support caching of responses with `Vary` header (possible without any changes on the client because since #8754 we're taking headers into account for the cache key) - fix browser caching of adjacent pages/endpoints fixes #9780 --------- Co-authored-by: S. Elliott Johnson <[email protected]>
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
System Info
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
No response
The text was updated successfully, but these errors were encountered: