use cache
Unanswered
African Slender-snouted Crocodil… posted this in #help-forum
African Slender-snouted CrocodileOP
Hey everyone! I’m running into a caching synchronization issue between Next.js server-side caching (using the new "use cache" directive) and client-side state management (React Query + Infinite Query).
The Problem:
When an admin updates a course price in the dashboard (e.g., from 4,600,000 to 4,300,000), the change reflects correctly on pages using client-side fetching (like our courses list page with React Query), but server components using "use cache" (like our landing page featuring top courses) still display the old cached price.
Questions:
Is this hybrid approach (combining Next.js "use cache" for SSR / Landing pages with React Query for filtered Client lists) considered valid and good practice in modern Next.js architecture?
What is the recommended / best-practice pattern to trigger server tag revalidation (revalidateTag / updateTag) when mutations are performed on the client?
Should we call a dedicated lightweight Server Action solely for calling revalidateTag inside React Query's onSuccess callback?
Or is it better practice to migrate client mutations entirely into Server Actions?
The Problem:
When an admin updates a course price in the dashboard (e.g., from 4,600,000 to 4,300,000), the change reflects correctly on pages using client-side fetching (like our courses list page with React Query), but server components using "use cache" (like our landing page featuring top courses) still display the old cached price.
Questions:
Is this hybrid approach (combining Next.js "use cache" for SSR / Landing pages with React Query for filtered Client lists) considered valid and good practice in modern Next.js architecture?
What is the recommended / best-practice pattern to trigger server tag revalidation (revalidateTag / updateTag) when mutations are performed on the client?
Should we call a dedicated lightweight Server Action solely for calling revalidateTag inside React Query's onSuccess callback?
Or is it better practice to migrate client mutations entirely into Server Actions?