Skip to content

Conversation

@RomanBobrovskiy
Copy link
Collaborator

@RomanBobrovskiy RomanBobrovskiy commented Feb 18, 2025

  • Support for Next.js v15: Added compatibility with the latest version of Next.js.
  • Cache Handling:
    • Updated storing cache data based on cache hit type.
    • Replaced max-age with s-maxage to rely solely on the CDN's cache instead of the browser's cache.
    • Included cache configuration documentation.
    • Added logic to check cache expiration.
    • Added mock cache entries for testing purposes.
  • Redirects:
    • Updated redirects lambda.
    • Utilized Next.js i18n configuration to handle redirects on the lambda side.
    • Updated redirect and locale redirects.
  • S3 Cache-Control:
    • Updated setting revalidation value in the Cache-Control file on S3.
  • Testing:
    • Moved tests under the tests folder.
    • Added new tests for different cache entry types (page, route, app page, fetch).
  • Package Update:
    • Updated @dbbs/cache-handler-common package to version 1.4.0, which supports Next.js v15.

@RomanBobrovskiy RomanBobrovskiy self-assigned this Feb 18, 2025
@RomanBobrovskiy RomanBobrovskiy changed the title feat/platform 1912 next multiple versions feat/PLATFORM-1912: Add support for Next.js v15, enhance cache handling, and improve redirects Feb 18, 2025
'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)}`
Copy link
Contributor

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}

Copy link
Collaborator Author

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)

Copy link
Collaborator Author

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'
})
)

Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@RomanBobrovskiy RomanBobrovskiy merged commit 72ef324 into main Feb 19, 2025
1 check passed
@RomanBobrovskiy RomanBobrovskiy deleted the feat/PLATFORM-1912-next-multiple-versions branch February 19, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants