-
Notifications
You must be signed in to change notification settings - Fork 87
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: make CDN SWR background revalidation discard stale cache content in order to produce fresh responses #2765
Draft
pieh
wants to merge
1
commit into
main
Choose a base branch
from
feat/make-swr-background-request-serve-fresh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
📊 Package size report 0.03%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
…t in order to produce fresh responses
3ab37f8
to
aca7cdd
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We are currently having "double SWR":
This leads to us having to instruct edge not to cache stale responses served by Next serverless handler as otherwise it would lead to stale content lingering for longer than it should.
This is optimistic change looking to explore option of disabling SWR behavior in serverless handler for the background refresh request coming from the edge. Today we can't yet distinguish those, so this is using not actually existing
x-background-revalidation
header that can be manually used on requests for testing purposesDocumentation
Tests
For now testing was done manually for various scenarios comparing those changes both against the way things work today and when deployed on Vercel - from those manual tests things seem to be working correctly:
a) served content remain the same as with current setup (just it leads to less invocations and ability to serve content directly from edge caches without blocking on serverless responses)
b) comparing against behavior when deployed on Vercel and reported status (
x-vercel-cache
)For our automated tests - right now no changes yet, as behavior should only be different when
x-background-revalidation
is provided. E2E can't really be changed yet ... unless we manually provide that header in our fetches/playwright navigations. Integration tests need some thought, as this doesn't entirely elimantate possibility of serving stale content by lambdas (which we can't just do as there are scenarios that still need it)Relevant links (GitHub issues, etc.) or a picture of cute animal
resolves https://linear.app/netlify/issue/FRB-1639/investigate-disabling-double-swr-behavior-in-next-runtime