I have a react native app that fetches a file from my server. When I change the file on the server, the app still displays the old data. I am debugging with expo.
I have:
-
Cleared the DNS cache with ipconfig
-
Cleared the cache on my server
-
Restarted my phone
-
Added the following to my fetch:
const response = await fetch(fileName, { headers: { "Cache-Control": "no-cache" },
-
Added the following to my fetch:
const response = await fetch(fileName, { headers: { "Cache-Control": "no-store" },
Used "expo start -c"
I still get the old data. When I renamed the file on the server and in the app, the new data appears.
2
Answers
Try to run or start again metro bundle with a reset cache flag.
Kinda works. If I did this alone. It did not work. Then I added the clear-cache to the header of the fetch and it did work. Then I took the clear-cache out and changed the file on the server and it didn’t work. So it looks like, unless someone has a better solution, I need to do both things to clear the cache.
Thanks – you got me farther and I was stuck.