简体   繁体   English

Next.js ISR(Incremental Static Regeneration),如何在interval/ISR时间开始前手动或动态重建或更新特定页面?

[英]Next.js ISR ( Incremental Static Regeneration ), how to rebuild or update a specific page manually or dynamically before the interval/ISR time start?

In NextJS Production mode - In Incremental Static Regeneration, I have placed an auto revalidate interval to 604800 seconds(7 days).在 NextJS 生产模式 - 在增量静态再生中,我将自动重新验证间隔设置为 604800 秒(7 天)。 In the meantime I may need to update a specific page before the interval time start.同时,我可能需要在间隔时间开始之前更新特定页面。

How can I rebuild/update a specific page without rebuilding the full site before the interval/ISR time start?如何在间隔/ISR 时间开始之前重建/更新特定页面而不重建整个站点?

currently next.js doesn't have a native feature for rebuilding a static page manually.目前 next.js 没有手动重建静态页面的本机功能。

here is a workaround you can refer to.这是您可以参考的解决方法

and next.js team is actively working on this topic, you can refer to this RFC并且 next.js 团队正在积极研究这个主题,你可以参考这个RFC

2022/04/07 update 2022/04/07 更新

on-demand-isr is in beta on-demand-isr 处于测试阶段

https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta

This is now possible in Next.js v12.1.这现在可以在 Next.js v12.1 中实现。

I saw this feature in the 12.1 release notes, it allows a manual cache purge for a page, on demand.我在 12.1 发行说明中看到了此功能,它允许按需手动清除页面的缓存。 using the unstable_revalidate() function.使用unstable_revalidate()函数。

I haven't tested it yet though but hope this helps.我还没有测试过,但希望这会有所帮助。

On Demand Incremental Static Regeneration (beta) 按需增量静态再生(测试版)

The feature is available and stable now.该功能现已可用且稳定。 I have done a simple test and created a module for it.我做了一个简单的测试并为它创建了一个模块。 It should solve the problem you have.它应该可以解决您遇到的问题。

On-Demand Incremental Static Regeneration (Stable) 按需增量静态再生(稳定)

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

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