Fredkiss3 / gh-next

A minimal Github clone built on nextjs app router.
https://gh.fredkiss.dev/
MIT License
450 stars 21 forks source link

Make it so that the BUILD_ID is only ever read once in the server lifetime #120

Closed Fredkiss3 closed 10 months ago

Fredkiss3 commented 10 months ago

Description

This PR is in response to a suggestion bylubieowoce to make it so that we don't read the BUILD_ID on every request https://x.com/lubieowoce/status/1741255877108101466?s=20

I couldn't make it so that the BUILD_ID is exported at the top of the file since next will try to compile the file and throw an error because the file .next/BUILD_ID doesn't exist at build time. So to mitigate this, we replaced the cache function from next with our custom lifetimeCache function which caches the results of operations for the whole the server lifetime, this way the BUILD_ID isn't read at build time, but only read at runtime once.

Type of Change

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gh-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 31, 2023 1:52am