On-Demand ISR doesn't revalidate more than once
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101
Binaries:
Node: 14.17.1
npm: 8.2.0
Yarn: 1.22.10
pnpm: N/A
Relevant packages:
next: 12.2.4
eslint-config-next: N/A
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
n/a
How are you deploying your application? (if relevant)
n/a
Describe the Bug
On-demand ISR
is implemented (on /api/revalidate
) and while it does flush the site cache once, hitting the endpoint a second time (or more) does not. This is happening in dev
as well as in production. CMS is used to fetch the content and to verify this bug, I have updated the content in between calls to /api/revalidate
Expected Behavior
Cache should be flushed each time with new content from the CMS (via getStaticProps
)
Link to reproduction
https://github.com/DTS-STN/Service-Canada-Labs
To Reproduce
- All pages in the app rely on
getStaticProps
to send a request to our CMS to get content. - There’s a revalidate API handler (
/api/revalidate.js
) created in our app with the following code:
const REVALIDATION_ROUTES = [
"/home",
];
export default async function handler(req, res) {
// Check for secret to confirm this is a valid request
if (req.query.secret !== process.env.REVALIDATION_TOKEN) {
return res.status(401).json({ message: "Invalid token" });
}
try {
await Promise.all(REVALIDATION_ROUTES.map((route) => res.revalidate(route)));
return res.json({ revalidated: true });
} catch (err) {
console.log(err);
return res.status(500).send("Error revalidating");
}
}
- There is no
revalidate
property option declared as part of thegetStaticProps
for any of the pages
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Incremental Static Regeneration - Data Fetching - Next.js
Note: Middleware won't be executed for On-Demand ISR requests. Instead, call revalidate() on the exact path that you want revalidated. For example, if...
Read more >A Complete Guide To Incremental Static Regeneration (ISR ...
ISR doesn't always make sense for small websites. If your revalidation period is larger than the time it takes to rebuild your entire...
Read more >On-demand ISR not working - Developing with Prismic
I made a revalidate.js in my api folder with the code below: // pages/api/revalidate.js import * as prismic from '@prismicio/client'; import ...
Read more >How to Update Static Content in Next.js Automatically with ...
Without ISR and revalidation, here's how content updates: Site builds; User requests site, receives static file; Content updates in headless ...
Read more >So what is with the revalidation delay in ISR? : r/nextjs - Reddit
ISR delays the first load like SSR (on-demand rendering), then serves ... more money scaling the backend, I increased revalidate time to 360 ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have a similar case, very much similar to the request above :
api/revalidate
endpoint;The result is:
Then I use Postman and trigger
api/revalidate
explicitly, and the page gets updated in a browser.Any thoughts on that?
For context: I want to use this feature to update hundreds and maybe thousands of pages in the future.Is it mature enough to rely on it or better to switch to SSR or revalidation with an interval?
Thanks!
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.