#refresh server fetch

1 messages · Page 1 of 1 (latest)

little coral
#

after I changed api on the other server - my nextjs project on server fetch still showing the old data, how do I force next server fetch to remove cache?

chilly roseBOT
#

Hi @little coral. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Next.js automatically caches data returned from fetch in the Data Cache. If you want to force a fetch request to bypass the cache and get the most recent data, you can use the cache option with the value no-store or force-no-store in your fetch request. Here's an example:

const res = await fetch('<https://example.com',> { cache: 'no-store' });

This will ensure that the fetch request does not use the cache and always gets the latest data from the server.

If you want to disable fetch caching for your entire Next.js application, you can do so by exporting fetchCache with the value force-no-store:

export const fetchCache = 'force-no-store';

In some cases, you might need to delete all cached data and force revalidation. You can do this by purging the Data Cache from your Vercel project settings. Here are the steps:

  1. Under your project, go to the Settings tab.
  2. In the Data Cache section, select Purge Everything.
  3. On the dialog, confirm that you wish to delete and click the Continue & Purge Everything button.

Please note that purging your Data Cache will create a temporary increase in request times for users as new data needs to be refetched.

For more information, you can refer to the Next.js Caching documentation (https://nextjs.org/docs/app/building-your-application/caching#fetch) and the Vercel Data Cache documentation (https://vercel.com/docs/infrastructure/data-cache/manage-data-cache).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: