-
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
fix: dynamic not-prerendered routes revalidate tracking #2771
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eb76546
fix: dynamic not-prerendered routes revalidate tracking
pieh 27a82bd
fix: correct typeof check
pieh ccf2788
test: adjust cache-status assertions for stale responses serverd by d…
pieh a353ed1
test: ensure we don't prerender API responses for og image in test fi…
pieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,12 +413,12 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { | |
expect(date1.localeCompare(beforeFirstFetch)).toBeGreaterThan(0) | ||
|
||
// allow page to get stale | ||
await page.waitForTimeout(60_000) | ||
await page.waitForTimeout(61_000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yes, I got tripped up by this too 😄 |
||
|
||
const response2 = await page.goto(new URL(pathname, pageRouter.url).href) | ||
expect(response2?.status()).toBe(200) | ||
expect(response2?.headers()['cache-status']).toMatch( | ||
/"Netlify (Edge|Durable)"; hit; fwd=stale/m, | ||
/("Netlify Edge"; hit; fwd=stale|"Netlify Durable"; hit; ttl=-[0-9]+)/m, | ||
) | ||
expect(response2?.headers()['netlify-cdn-cache-control']).toMatch( | ||
/s-maxage=60, stale-while-revalidate=[0-9]+, durable/, | ||
|
@@ -436,8 +436,8 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { | |
const response3 = await page.goto(new URL(pathname, pageRouter.url).href) | ||
expect(response3?.status()).toBe(200) | ||
expect(response3?.headers()['cache-status']).toMatch( | ||
// hit, without being followed by ';fwd=stale' | ||
/"Netlify (Edge|Durable)"; hit(?!; fwd=stale)/m, | ||
// hit, without being followed by ';fwd=stale' for edge or negative TTL for durable, optionally with fwd=stale | ||
/("Netlify Edge"; hit(?!; fwd=stale)|"Netlify Durable"; hit(?!; ttl=-[0-9]+))/m, | ||
) | ||
expect(response3?.headers()['netlify-cdn-cache-control']).toMatch( | ||
/s-maxage=60, stale-while-revalidate=[0-9]+, durable/, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ export async function GET() { | |
height: 630, | ||
}) | ||
} | ||
|
||
export const dynamic = 'force-dynamic' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ export async function GET() { | |
} | ||
|
||
export const runtime = 'edge' | ||
|
||
export const dynamic = 'force-dynamic' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ export async function GET() { | |
height: 630, | ||
}) | ||
} | ||
|
||
export const dynamic = 'force-dynamic' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ export async function GET() { | |
} | ||
|
||
export const runtime = 'edge' | ||
|
||
export const dynamic = 'force-dynamic' |
Oops, something went wrong.
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.
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'm assuming we don't have to do this at build time too?
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.
We still record
initialRevalidateSeconds
fromprerender-manifest.json
underrevalidate
opennextjs-netlify/src/build/content/prerendered.ts
Line 69 in 3301077
Which is enough for how we read this value later for own needs (like figuring out initial cdn max age in some cases - like recently merged 404 caching fixes or preventing double SWR ) and Next.js also uses
prerender-manifest.json
directly for anything that was prerendered ( https://github.com/vercel/next.js/blob/7e5e69dd2592e2b8d165d15b267ba3491f7d8174/packages/next/src/server/lib/incremental-cache/shared-cache-controls.ts#L36-L67 ), so we don't have to actually do the same at build time - otherwise we would also need to adjust our own code in places we rely onrevalidate
field.That is possibly something to think about, because
cacheControl
field does containexpire
togetherrevalidate
, so this would allow exactstale-while-revalidate=
value for cases that useopennextjs-netlify/src/run/headers.ts
Lines 201 to 212 in 3301077
So technically it might not be correct not to store it, but it probably be better for some follow up as amount it's already here is addressing substantial problem (with those next versions we never cache not-prerendered dynamic pages on cdn now)
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.
So I'll go ahead and merge this