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.
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.
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.
reused function from nextjs
| ContentType: 'text/html' | ||
| }) | ||
| ) | ||
|
|
There was a problem hiding this comment.
Maybe add a default statement?
i.e.
default:
console.warn(Unhandled route kind: ${data.value.kind})
return
Uh oh!
There was an error while loading. Please reload this page.