#React Server Components caching in Next.js 15 doesn't seem to work?

2 messages · Page 1 of 1 (latest)

thick vale
#

So this is my api call function:

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?

crude cloakBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)