Next.js Discord

Discord Forum

Which cache system on fetch allow me to presist data ( hit the cache ) until I refresh the whole pag

Answered
Siberian Accentor posted this in #help-forum
Open in Discord
Avatar
Siberian AccentorOP
When I use cache:"force-cache", it doesn't remove on page refresh, which one does this use case ?
Answered by B33fb0n3
To conclude your issue:
When using cache tags or even revalidation times (like here: https://nextjs-forum.com/post/1330892443935309846#message-1330917315717365764), they get revalidated after time or when the tag is revalidated
View full answer

17 Replies

Avatar
Siberian AccentorOP
force-cache is aggressively caching, but I want to dump the cache on refresh
Avatar
Siberian AccentorOP
anyone please ?
Avatar
@Siberian Accentor When I use cache:"force-cache", it doesn't remove on page refresh, which one does this use case ?
Avatar
you can use a clientside fetching library if the fetches are called from the client. React Query or SWR have a caching system.

If you speak about serverside stuff, you want to clarify what you are building and why you want what
Avatar
Siberian AccentorOP
I'm using the force-cache - so does it mean I'm caching on the server-side ?
like I'm using coolify and if I use deploy without cache - the user get the fresh data ?
my concern is - if my api data changes
Avatar
@Siberian Accentor I'm using the force-cache - so does it mean I'm caching on the server-side ?
Avatar
yes, that would be inside the cache of the server. How often do you want to update your page with fresh data? Every X hours?
Avatar
Siberian AccentorOP
I have relidation tag with 1 day,
I think I understand now
I didn't understand until now
 // Use force-cache for route navigation
          cache: "force-cache",
          next: {
            tags: [`questions-${cacheKey}`],
            revalidate: 86400, // Revalidate after 24 hours
          },
Avatar
Siberian AccentorOP
another question I have is:
is this like cdn ?
If one person fetch it, does the other person are hitting the server cache ?
Avatar
@Siberian Accentor If one person fetch it, does the other person are hitting the server cache ?
Avatar
yes, if I as a client get cached data, you get the same data as well, for the same request
Avatar
Siberian AccentorOP
okay, thanks 🙏
Avatar
To conclude your issue:
When using cache tags or even revalidation times (like here: https://nextjs-forum.com/post/1330892443935309846#message-1330917315717365764), they get revalidated after time or when the tag is revalidated
Answer
Avatar
happy to help