Back

how to Disable Caching in Next js for appwrite fetching.

  • 0
  • Databases
  • Web
Mohiuddin
23 Sep, 2024, 13:16

hey there, I am facing an issue when I have any new data in my database i can't see it because of the next js cashing. how can I disable it? I can do it with the next.js fetch method, but here I am confused.

TL;DR
To disable caching in Next.js for Appwrite fetching, use the `revalidatePath("path");` function where data is added, updated, or deleted. Replace `"path"` with the URL of the documents. For cookie-related concerns, use `const _ = cookie()` at the beginning of the function. This approach should resolve the issue with Next.js caching causing new data in the database not to be visible.
Suiii
23 Sep, 2024, 13:23

try const _ = cookie() first line of your function

Mohiuddin
25 Sep, 2024, 06:35

do you mean cookies from next/header?

Suiii
25 Sep, 2024, 15:43

first line of the function , you don't want cache.

Guille
25 Sep, 2024, 17:27

you can try this:

TypeScript
revalidatePath("path");

Use this function where you add, update or delete data. path is the URL where you list/get the documents.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more