Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Nextjs Incremental Static Generation, cache clear

I have an issue with using incremental static generation with Nextjs framework, I am using getStaticPath and getStaticProps As the following code

export const getStaticPaths: GetStaticPaths = async () => {
const paths = [{ params: { username: 'kelly' } }];

return {
    paths,
    fallback: true
};
};

export const getStaticProps: GetStaticProps = async (context: any) => {
    const username = context.params.username;
    /* api call getUserData */
    const userData = await getUserData(username);
    if (!userData || userData.images.length < 1) {
        return {
            notFound: true
        };
    }

    return {
        props: {
            userData
        },
        revalidate: 300
    };
};

Everything works fine as expected
if i update the user endpoint api, the user page gets updated , and using fallback = true, the page is rebuilt every 300s , so all is good here.

the problems begin if i delete a user ( example user1) , (in my case when the api endpoint is rendering no data for user1). The page that has the path (/myapp/user1 ) should give a 404 as expected in the code instead of that -I am getting a 404 page for only 20min, then the 404 page is replaced by a cached page (seems to be the latest static page that nexts has built for this path)

it looks like for Nextjs, as long as a static page has already been built for a given path myapp/user1, if later this page no longer exists (404 or redirect404), Nextjs will serve the page it has in the cache (the latest page that was built),

The only way I found to remove the static page and get the 404 for the page, is to redeploy (to perform a rebuilt npm run build)

Please help: -Is there an option to change this cache config in nextjs, if yes how and where / -Is it a lack of option for Nextjs when using Incremental static generation ? -also for unknown reason it works fine on stage but on production it s not working.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!