skip to Main Content

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


  1. Try to run or start again metro bundle with a reset cache flag.

    npm start --reset-cache
    yarn start --reset-cache
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search