Next.js Discord

Discord Forum

Disabled caching on localhost but on production it is enabled?

Answered
DanielHigh posted this in #help-forum
Open in Discord
Hello, I have a problem with caching I guess. I've disabled all caching using { cache: "no-store" } and everything is working correctly on my localhost.

But on the production my api is using only it seems like the first data from the build and then it is not refreshing. Basically if I send two requests in my postman, from localhost and from the live production I get two different results.

This is my source code:
https://github.com/DanielHighETH/unibot-revenue-calculator

Live is on: https://unibot-revenue.com/ and the endpoint is /api/getData.
Answered by fuma
export const revalidate = 0;

export function GET() {
  ...
}
View full answer

13 Replies

Miniature Fox Terrier
Yes, this cache problem is really growing. There should be a solution.
Miniature Fox Terrier
They gave me this answer;

they cache the component in the user for 30s
https://github.com/vercel/next.js/pull/48383
its only client side so you shouldnt worry about it
It is definitly not 30 seconds for me here... im getting the data when i build the app and then it is like its not fetching new data anymore, just using the old one..
Have you tried to set revalidate = 0 on the page level (segment config)?
I think it is not working still...

I feel like the page is pre-loaded with the data since the build. It is taking less time to load on production then on localhost.

On localhost when i run npm run dev it takes a bit more time to load the page but with correct data...
@fuma Have you tried to set `revalidate = 0` on the page level (segment config)?
You ment it like this right?
    const unibotPriceRes = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=unibot&vs_currencies=usd&time=${Date.now()}`, {
      next: { revalidate: 0 }
    });
Answer
in the route handler
GET Route handlers are cached by default too
@fuma ts export const revalidate = 0; export function GET() { ... }
oh yeah just found it... thanks a lot it is working
Glad to hear that! You can mark my answer as the solution if your problem has been solved :AyameHappy: