-
-
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
feat: Support caching of responses with Vary
header, and fix browser caching of adjacent pages/endpoints
#9993
Conversation
🦋 Changeset detectedLatest commit: a0a4d3a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks for the contribution! Just a couple of comments from me 😁
Co-authored-by: S. Elliott Johnson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Note to self: This is now possible without any changes on the client because since #8754 we're taking headers into account for the cache key.
Edit: I created an issue: #10366 This change broke an app of mine. When returning a Is there a good fix for this or do I have to clone the response-object so that the headers are mutable again? 🤔 Example for reproduction+server.ts import type { RequestHandler } from './$types';
// Proxy requests to API
export const GET = (async ({ request }) => {
const headers = new Headers({ Authorization: `Bearer xyz` });
return await fetch('https://api.test/', {
method: request.method,
headers,
body: request.body,
// @ts-ignore: https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1483
duplex: 'half'
});
}) satisfies RequestHandler; |
(fixes #9780)
Expand below to see recorded GIF of the issue - notice that on "forward" navigation the browser renders the endpoint response from cache, instead of the expected HTML response.
Before/after
Before
After
Vary: Accept
header on responses toGET
requestsVary
(as long as it's notVary: *
)Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.