Next.js Discord

Discord Forum

Disabling caching of server actions in server components

Unanswered
Capple posted this in #help-forum
Open in Discord
Hey, I wanted to ask if the caching could be disabled on the straight database call?
If i make some changes on the planogram, navigate between pages and come back to this page, it loads the previous state.

I couldn't get it to work with revalidate etc. Is my only option to create a route handler and use fetch?

xport default async function PlanogramPage({ params }: { params: { uuid: string } }) {
  const { uuid } = params;

  let planogram;
  try {
    planogram = await loadPlanogram(uuid);

    if (!planogram) {
      notFound();
    }
  } catch {
    notFound();
  }

  return <PlanogramView planogram={planogram} />;
}

1 Reply

Kurilian Bobtail
Think you want to add:
const dynamic = 'force-dynamic'
to your page.tsx

See https://nextjs.org/docs/app/guides/caching#segment-config-options