Skip to content

Deleted page still appears after revalidation in Next.js #2781

Closed
@lotarbo

Description

@lotarbo

Hi. When I delete an article and trigger revalidation in Next.js, the page is still accessible for over an hour. Only after that delay does the non-existent URL correctly return a 404.
It seems like netlify is not properly invalidating the cache. Because locally (npm run build && npm run start) everything works as it should.

I'm using next.js 14.2 and pages route.
Next.js Runtime - v5.10.1

my src/pages/blog/[slug].tsx has:
in getStaticPaths
fallback: "blocking",
in getStaticProps
revalidate: 3600
and return 404 if no article data

 if (!articleData) {
        return {
            notFound: true,
        };
    }

I have a webhook set up from sanity for each change. and in api/revalidate.ts I have await res.revalidate(path);

I created an article with slug example-1
It becomes available at blog/example-1
I change the content - the changes are visible almost immediately at blog/example-1
I delete this article, and instead of 404 I see the article.
It seems that the problem is already in the netlify cache, coz i see this headers

age: 1343
cache-control: public,max-age=0,must-revalidate
cache-status:"Netlify Edge"; hit
...

Or maybe incorrect handle on-demand and time based revalidation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions