Dynamic Routes

When you render a dynamic route like test/[slug] this becomes a dynamic route automatically. This means you will never see a cache HIT.

You can do export dynamic="force-static" if you want the pages to be cached after they are rendered for the first time. For example if you have blog pages or product pages. You want them to be cached after first render.

If you want all of those pages being cached already at build time you can use

export async function generateStaticParams() {
  const pages = await getPages();
  return pages.map(p => ({ slug: p.slug}))

This way all the generated pages are being static and cached as well. But this will increase the build times for larger sites significantly.

When a page is requested that was not generated, by default, it works like "force-static". Meaning the page will be dynamically rendered but then cached.

©️ 2024 Digitale Kumpel GmbH. All rights reserved.