#Server component - fetched data is not updated

22 messages · Page 1 of 1 (latest)

stiff basin
#

Hello,I have a server component that fetches some data from Supabase and display it.

If I change some info inside the table, the data fetched in production dosen't change, no matter hard refresh/ etc.

I don't get what could be the problem.

export const revalidate = 0;

async function fetchCoins() { let { data } = await supabase.from("xCoins").select("*").order("votes", {ascending: false }); return data; }

async function CoinTable() { 
const coins = await fetchCoins(); 
return (
    // Here I display fetched data. It does not update at refresh.
    <div>{coins}</div>
);
}
wide gull
#

I dont know how different it is from the fetch API, but I think this is intended behaviour, as it fetches only once when you build the application and puts it into the cache and everytime you navigate to this page, you are gonna get the same cached data.

#

set the revalidate to 10

#

Then the page should update every 10 seconds if there is a change in the table

stiff basin
#

As far as I saw, i have to add this to the fetch().

{ next: { revalidate: 10 } }

But im using supabase integration to get the data so I am a bit confused.
This dosen't seems to work.

#

let { data } = await supabase.from("xCoins").select("*").order("votes", { ascending: false }, { next: { revalidate: 10 } });

steep ginkgo
#

{ next: { revalidate: 10 } } is only relevant when you're calling fetch. It doesn't do anything with supbase

#

Try changing export const revalidate = 0; to export const revalidate = 10;

stiff basin
#

It is deployed like that but as far as i see, does not fix the issue. If I change some data inside supabase and refresh the page, even after 10 sec/ 1 min/ 1h, etc., nothing changes.

steep ginkgo
#

@stiff basin something else must be going on then, I just tested this locally myself. Using a export const revalidate = 5 I was able to see Next refetching data and displaying the updated content

#

you're sure you're changing data in the prod version of your supabase DB? Not a dev db by mistake?

#

Try adding in a console log to the component itself, you should see the log statement during revalidation

stiff basin
#

Are we talking about a server component?

#

I just updated to latest Next version - 13.1.5 (it tought it might be related) but still nothing fixed

#

I have those Vote buttons that chamge the vote count in database

#

Altough when I vote, the data is updated in DB, in browser nothing is updated

#

No matter how I try (refresh/ etc.)

acoustic shell
#

Why not disabling the cache?

stiff basin
#

How?

#

I saw in the documentation just for the fetch()

#

I don't know how can i do it for supabase