-
Notifications
You must be signed in to change notification settings - Fork 0
feat/PLATFORM-1912: Add support for Next.js v15, enhance cache handling, and improve redirects #54
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/PLATFORM-1912: Add support for Next.js v15, enhance cache handling, and improve redirects #54
Conversation
src/cacheHandler/strategy/s3.ts
Outdated
| 'Cache-Fragment-Key': cacheKey | ||
| }, | ||
| ...(data.revalidate ? { CacheControl: `smax-age=${data.revalidate}, stale-while-revalidate` } : undefined) | ||
| CacheControl: `s-maxage=${data.revalidate || CACHE_ONE_YEAR}, stale-while-revalidate=${CACHE_ONE_YEAR - (data.revalidate || 0)}` |
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 a bit clunky for me
Maybe we can use a new variable and add a check
const revalidate = Math.max(0, Math.min(data.revalidate ?? CACHE_ONE_YEAR, CACHE_ONE_YEAR))
...
CacheControl: s-maxage=${revalidate}, stale-while-revalidate=${CACHE_ONE_YEAR - revalidate}
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.
the issue that revalidate type is boolean or number
so when it is 0 we avoid caching at all and have early return
otherwise if revalidate is false we set 1 year as default cache behaviour (this is what nextjs does under the hood)
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.
reused function from nextjs
| ContentType: 'text/html' | ||
| }) | ||
| ) | ||
|
|
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.
Maybe add a default statement?
i.e.
default:
console.warn(Unhandled route kind: ${data.value.kind})
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.
updated
Uh oh!
There was an error while loading. Please reload this page.