Open akash3444 opened 2 weeks ago
Seeing the same. Strange
I'm going with a workaround until we find a proper solution to this issue. I have created a function that returns a GraphQL endpoint with the random id as the value of a query parameter. This solves the issue and always returns the latest result.
export const getGraphQlEndpoint = () => `${process.env.NEXT_PUBLIC_GRAPHQL_API_URL}?id=${new Date().valueOf()}`;
You can customise this with the revalidate option: https://nextjs.org/docs/app/api-reference/functions/fetch#optionsnextrevalidate. You could set it to 0
which means no cache, which is what you want.
@bitttttten I tried that too. But, it does not seem to work.
folllow
Link to the code that reproduces this issue
https://github.com/akash3444/hashnode-clone
To Reproduce
152583c5-71a6-4481-94b0-7d64e771d453
.Matikiri NET
. But, I'm seeing the cached result which displays that I'm not following that user.Current vs. Expected behavior
Current Behavior: Next.js caches the GraphQL API results and displays the same result everytime. Using cache
no-store
and revalidate0
also does not work. The only way to prevent that API from being cached is to pass a parameter with the random value each time to the API.Expected Behavior: It should not cache the GraphQL API as I'm already passing
{ cache: 'no-store' }
to the fetch API options.Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
No response