3

I am using next.js 10 and have a [slug] page which creates dynamic pages from Contentful CMS. I am changing the slug inside CMS and run next dev the old slug correctly returns 404 and the new slug works.
However when I build and run next start the old slug still returns a cached page, the new slug works properly.
I am returning revalidate 10 and have assumed the page should refresh after 10sec

export const getStaticProps: GetStaticProps<SlugRoutePageProps> = async ({
  params,
}) => {
  ....  
  ....
  const pageData = await getPageData(params.slug)
  if (pageData.total === 0) return { notFound: true }

  return {
    props: {
      pageType: "DynamicPage",
      pageProps: {
        pageData,
      },
      revalidate: 10,
    },
  }
}

in getStaticPaths I have fallback: "blocking", also tried fallback: true with no difference.

Edit:
getPageData is a basic call to the contentful api - no caching

   const getPageData = async (
      slug: string,
    ): Promise<FetchPagesResult> => {
      const client = createContentfulClient()
      return client.getEntries<Page>({
        content_type: "page",
        "fields.slug": slug,
        include: 5,
        order: "-sys.updatedAt",
        limit: 1,
      })
    }
jeff
  • 1,169
  • 1
  • 19
  • 44
  • Have you check your api cache? Please provide getPageData function code and the server side as well – Darryl RN Jan 08 '21 at 00:38
  • I have added the getPageData function in my question - it doesn't do anything fancy - just a basic contentful api call with no caching - I don't think it causes the problem – jeff Jan 08 '21 at 12:29
  • Hello, did you find a solution yet? I have a similar problem: https://stackoverflow.com/questions/67864802/next-js-isr-page-not-being-deleted-after-deleting-it-in-cms – Mark Jun 08 '21 at 06:04

0 Answers0