如何在每天的特定时间让NextJS重新生成静态页面?

发布于 2025-02-10 06:27:49 字数 210 浏览 1 评论 0 原文

我有一个NextJS应用程序和DRF后端。在NextJS应用程序中,我有一个排行榜页面,该页面从DRF后端摘下数据。但是,此排行榜页面每天仅更新一次。因此,我想的是我希望我的Nextjs能够一次拉动API(也许在凌晨3点),并生成一个静态站点,因此该网站会很快加载(因为最多可容纳1000个访问者我需要网站快)。这可能吗?赦免我,我是NextJS的新手。

I have a NextJS application and a DRF backend. In the NextJS application, I have a leaderboard page which pulls data from the DRF backend. However, this leaderboard page is updated only once a day. So, what I'm thinking is I want my NextJS to be able to pull the API once (maybe at 3AM), and generate a static site, so the site would load quickly (as there can be up to 1000 visitors at once so I need the website to be fast). Is this possible? Pardon me I'm very new to NextJS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

錯遇了你 2025-02-17 06:27:49

您可以尝试使用新功能“按需重新验证”尝试“增量静态再生”,但仍处于beta中!完成后,从您的排行榜页面上设置一个呼叫,以触发NextJS页面的新一代。

请参阅文档:

You can try "Incremental Static Regeneration" with the new feature "On Demand Revalidation" but it is still in beta! Set up a call from your leaderboard page when it is finished to trigger the new generation of the nextjs page.

See the documentation: https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#on-demand-revalidation-beta

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文