-
Notifications
You must be signed in to change notification settings - Fork 86
test: added tests to check that the vary header contains 'RSC' #1993
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
Conversation
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
331a956
to
ae79440
Compare
513d23e
to
660afd5
Compare
660afd5
to
958fb89
Compare
9073caf
to
2620db5
Compare
|
||
// Set the 'vary' header to 'RSC' to ensure that we cache correctly for the different | ||
// possible content-types: application/octet-stream and text/html | ||
request.headers.set('vary', 'RSC') |
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.
Shouldn't this be on the Response?
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.
Yeah, you're right. Not sure why I put it on the request (late night coding 🙃 ), and also not sure why my tests and curl
s pass. 🤔
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.
It already worked. The problem isn't it returning the wrong data - that was already fixed. The problem is the browser caching the wrong data. The tests should be checking that the server is returning the Vary
header, and you can manually test it in the browser with the instructions in https://github.com/netlify/pod-ecosystem-frameworks/issues/352
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.
I've added tests to check for the vary header. Oddly enough, it looks like the vary header is working already. I removed my change and just updated tests.
scope of the PR changed. It's only tests now.
* Revert "test: added tests to check that the vary header contains 'RSC' (#1993)" This reverts commit 124d4ae. * Revert "Revert "test: added tests to check that the vary header contains 'RSC' (#1993)"" This reverts commit 4731be5. * test: skipping vary header test for rsc for now until issue is fixed
Summary
Fixes an issue where requests coming in to the edge function that were handling React Server Components were always returning the first cached response causing issues with serving the content typetext/html
orapplication/octet-stream
It looks like the
vary
header is already in the response, so I've added tests to ensure it remains.Closes https://github.com/netlify/pod-ecosystem-frameworks/issues/352
Test plan
There is an end-to-end test in this PR that tests that this works, but you can also curl the deploy preview to see it working.
curl -v https://deploy-preview-1993--netlify-plugin-nextjs-demo.netlify.app/blog/erica/
. The content type returned iscontent-type: text/html; charset=utf-8
curl -v -H "RSC: 1" https://deploy-preview-1993--netlify-plugin-nextjs-demo.netlify.app/blog/erica/
, The content type returned iscontent-type: application/octet-stream
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was published correctly.