Introducing next-boost. A drop-in caching layer for SSR next.js servers #13705
Unanswered
rjyo
asked this question in
Show and tell
Replies: 1 comment 7 replies
-
Very interesting for SSR-focused Next.js apps! I'm building something "similar" (Next.js boilerplate "Next Right Now"), but it's very different regarding the goal and implementation, as it rather focuses on SSG 😉 I've added Next Boost as a NRN alternative, and I hope I can take a deeper look at some point to learn how you've implemented some of the features that would benefit NRN! |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is an introduction of a micro-caching layer I build called
next-boost
. It can be considered as an implementation of Incremental Static Regeneration which works withgetServerSideProps
.Background
I'm working on several relatively large-scale SSR websites (100K+ pages at most) with AMP. With With next.js, I can build these full-AMP websites with all the modern toolchains and it feels great. Due to their scale and the designs and functions are evolving quite fast, SSG is not an option. (Yep, I came from Gatsby after tried all kinds of optimizations)
As React's VDOM rendering is a CPU-bound task, use next.js as an SSR server alone will be relatively slow. By saying "slow", it's like that your data was fetched in 100ms while the whole page rendered in 1500ms.
next-boost
is drop-in middleware for next.js. And it helps me to run the sites fast even on entry-level VPSs.Here are the main features:
stale-while-revalidate
micro-caching strategy (serves the cached version while updating it in the background)worker_threads
and the cache is always served instantly on the main threadAnd, you can also get these benefits comparing to SSG
next build
then sync the.next
directory). It used to take us 15 mins for SSG and uploading all the generated files. With full SSR, it takes less than 1 min.So how was it comparing to next.js's support for
getStaticProps
andfallback: true
? As the fallback mode utilizes the client-side rendering when the page's not ready, it doesn't work for a pure SSR + AMP stack.There are more discussions about SSG and
fallback
in this thread:#11552 (reply in thread)
Implementation
The repo is here: https://github.com/rjyo/next-boost, with detailed API usages.
The easiest way to integrate it with next.js is,
npm i next-boost
next start
tonext-boost
.next-boost.js
at the project root as below. Now all the pages will be served from cache and revalidated after 60 seconds.More API and explanation can be found in the README.
At the end
Many thanks to the superb team and community for building this great product!
This is the first time for me to write such a long post at Github. I hope it helps someone. And you are welcomed for any questions or advice.
Beta Was this translation helpful? Give feedback.
All reactions