-
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: set netlify-cache-tag for not prerendered content #2495
Conversation
📊 Package size report -0.02%↓
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
3bccb0f
to
74983c0
Compare
…ses for not prerendered content
…cases for not prerendered content
74983c0
to
bd713be
Compare
… manifest created for prerendered pages
6ce8636
to
4b6de32
Compare
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.
LGTM, nice work! Thanks for the explanations and comments.
@@ -311,47 +311,6 @@ export const copyNextDependencies = async (ctx: PluginContext): Promise<void> => | |||
}) | |||
} | |||
|
|||
export const writeTagsManifest = async (ctx: PluginContext): Promise<void> => { | |||
const manifest = await ctx.getPrerenderManifest() |
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.
Looks like we can delete this 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.
... Oh, I don't think this is related to your changes, but still dead code
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, not really related to this change, but I did remove it now
// Bail if we already have cache tags - `captureCacheTags()` is called on both `CacheHandler.get` and `CacheHandler.set` | ||
// that's because `CacheHandler.get` might not have a cache value (cache miss or on-demand revalidation) in which case | ||
// response is generated in blocking way and we need to capture cache tags from the cache value we are setting. | ||
// If both `CacheHandler.get` and `CacheHandler.set` are called in the same request, we want to use cache tags from | ||
// first `CacheHandler.get` and not from following `CacheHandler.set` as this is pattern for Stale-while-revalidate behavior | ||
// and stale response is served while new one is generated. | ||
if (requestContext.responseCacheTags) { | ||
return | ||
} |
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 trying to think of something less leaky but I can't 😞
Co-authored-by: Philippe Serhal <[email protected]>
d1075a7
to
29607db
Compare
Description
We are currently relying on
tags-manifest.json
to setnetlify-cache-tag
response header. Tags Manifest is produced at build time from prerendered content so it won't contain any not prerendered pages which will result in this header missing for not prerendered pages and therefore make it impossible to purge CDN cache (it's still possible to invalidate Next.js cache, but if there were CDN nodes that already cached content - we aren't able to purge that right now). This might result in "random response" being served to user depending on which CDN handled the request (it might be fresh response or it might be old response that was cached)Tests
Added failing E2E test cases in first 2 commits for both App and Pages Router
Relevant links (GitHub issues, etc.) or a picture of cute animal
https://linear.app/netlify/issue/FRP-566/nextjs-routes-revalidating-when-not-required#comment-1bf42469