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
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
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
17 Replies
Siberian AccentorOP
force-cache is aggressively caching, but I want to dump the cache on refresh
Siberian AccentorOP
anyone please ?
@Siberian Accentor When I use cache:"force-cache", it doesn't remove on page refresh, which one does this use case ?
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
If you speak about serverside stuff, you want to clarify what you are building and why you want what
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
@Siberian Accentor I'm using the force-cache - so does it mean I'm caching on the server-side ?
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?
Siberian AccentorOP
I have relidation tag with 1 day,
I think I understand now
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
},
@Siberian Accentor typescript
// Use force-cache for route navigation
cache: "force-cache",
next: {
tags: [`questions-${cacheKey}`],
revalidate: 86400, // Revalidate after 24 hours
},
then it will be revalidated only every 24 hours or when you revalidate your tag
Siberian AccentorOP
another question I have is:
is this like cdn ?
is this like cdn ?
If one person fetch it, does the other person are hitting the server cache ?
@Siberian Accentor If one person fetch it, does the other person are hitting the server cache ?
yes, if I as a client get cached data, you get the same data as well, for the same request
Siberian AccentorOP
okay, thanks 🙏
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
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
happy to help