-
Notifications
You must be signed in to change notification settings - Fork 26
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
Moving to JAMstack #1051
Comments
Great summary! And very cool techniques with iSSG. I think stage 1 might be the most significant, as it already satisfy the philosophy of JAMstack, and we can already start utilizing CDN. Stage 2 should be an optional plus, since it speeds up the process from SSR server to CDN. iSSG is not really static webpages that can be cached in CDN, it's a cache inside SSR server. But it's definitely a cool technique worth trying: vercel/next.js#11552 |
One thought: Disable SSR for protected routes (e.g. |
It looks like there's no common ways of defining directives for client side, and it is also a non-trivial logic to mark certain fields as SPA only, skip them during SSR, and reassemble then during SPA. I think splitting SSR and SPA fragments at component level makes more sense, and gives us more control. For example, we can leave the current fragment pattern unchanged, and use |
Background
We are suffering from website instability caused by traffic grows. And it's hard to keep it fast without putting more cloud resources, like adding more servers.
Ideally, we should make as much request resources as possible as static, and served by CDN. That's what JAMstack for:
Architecture
We mainly use these two frameworks to build and run matters.news:
In our current architecture,
/:username
,/follow
, etc.) are rendered (SSR) by Next.js server on-demand, at runtime, with API calls, then served & cached by CDN in a short TTL.Because the CDN cache pages by token (user-specific data) and short TTL (fresh data), the hit rate is low.
Solutions
Guiding by the philosophy of JAMstack, based on the restrictions [1][2] of the tech stack we used, we can do the optimization in stages.
Stage 1
Stage 2
getStaticProps
andgetStaticPaths
(withfallback: true
) to serve dynamic pages in iSSG (Incremental Static Site Generation);References
[1] iSSG may bad for SEO: loading indicator will be shown if the page has never been rendered before;
[2] Need to refactor API queries:
next-with-apollo
usesgetInitialProps
and still not support forgetStatic*
methods[3] https://nextjs.org/blog/next-9-3#fallback-true
[4] https://static-tweet.now.sh/
The text was updated successfully, but these errors were encountered: