简体   繁体   English

SSG和SSR如何选择?

[英]How to choose between SSG and SSR?

I am currently exploring Nextjs and building a website with the same framework.我目前正在探索 Nextjs 并建立一个具有相同框架的网站。 The website has a public flow, protected routes (such as user dashboard, user project details, and general user data), and product pages.该网站具有公共流程、受保护的路线(例如用户仪表板、用户项目详细信息和一般用户数据)和产品页面。

The question is, how do i choose between SSG and SSR a particular route.问题是,我如何在 SSG 和 SSR 之间选择一条特定的路线。 This has been my strategy so far到目前为止,这是我的策略

  1. All static pages (forms, user input) - SSG所有 static 页面(表单、用户输入)- SSG
  2. BLOG links to be all SSG BLOG链接全部为SSG

My questions are:我的问题是:

  1. The dashboard and the user details pages will not real time data, but data that might have project specific info.仪表板和用户详细信息页面将不是实时数据,而是可能包含项目特定信息的数据。 Is this a use case SSG with incremental revalidation, or SSR?这是具有增量重新验证的用例 SSG 还是 SSR?

  2. The publicly available product details pages.公开可用的产品详细信息页面。 There might be upwards of a thousand products.可能有超过一千种产品。 In such cases, does the long build process of pre rendering the product pages outweigh the potential seo benefits?在这种情况下,预渲染产品页面的漫长构建过程是否超过了潜在的 seo 好处? Because this seems like an ideal case for SSG with revalidation.因为这似乎是 SSG 重新验证的理想案例。 Or is it best suited for SSR?还是最适合 SSR?

Thanks in advance!提前致谢!

It's clear you know the difference between the two/three options.很明显,您知道两个/三个选项之间的区别。

  1. SSG - hydrate using client-side queries. SSG - 使用客户端查询进行水合物。
  2. SSG - might have thousands of products SSG -可能有数千种产品

Premature scaling is never a good idea and you rarely end up with a good solution for both scenarios.过早的扩展从来都不是一个好主意,而且你很少会为这两种情况找到一个好的解决方案。 SSG is likely better now but you could use ISR - however, go with the solution that solves today's problem. SSG 现在可能会更好,但您可以使用 ISR - 但是,go 具有解决当今问题的解决方案。

A static site with 1,000 pages can lint & build in ~2 minutes.拥有 1,000 个页面的 static 站点可以在大约 2 分钟内完成 lint 和构建。 It's often more cost effective (time, effort, and hosting cost) to use SSG and use a different solution when you know your bottlenecks.当您知道瓶颈时,使用 SSG 并使用不同的解决方案通常更具成本效益(时间、精力和托管成本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM