React Server Components caching in Next.js 15 doesn't seem to work?
Unanswered
Alligator mississippiensis posted this in #help-forum
Alligator mississippiensisOP
So this is my api call function:
I call this in a React Server Component like
but in my logs I get this info:
I also tried to wrap the whole
what am I missing?
export const getList = async (): Promise<
ListType | undefined
> => {
try {
const response = await fetch(`${API_URL}/list`, {
cache: "force-cache",
next: {
tags: ["list"],
},
headers: {
Authorization: AUTH_HEADER,
},
});
const data: ListType = await response.json();
return data;
} catch (error: unknown) {
console.error(`Error fetching list: ${error}`);
return;
}
};
I call this in a React Server Component like
const data = await getList();
but in my logs I get this info:
2024-11-11 11:51:02 │ GET https://some-url.com/api/hosts/r34234e23423/list 200 in 447ms (cache skip)
2024-11-11 11:51:02 │ │ Cache skipped reason: (cache-control: no-cache (hard refresh))
I also tried to wrap the whole
getList
function in react.cache
which is also not working.what am I missing?
1 Reply
Alligator mississippiensisOP
it seemed to work once I restarted / rebuilded the app. So just changing
cache
without rebuilding the app didn't catch the changes. interesting