3

I have a firebase app made with React (create-react-app), and we are about to launch our first version.

Unfortunately, every time we deploy new changes, current users (using Chrome) can’t see the changes until they hit cmd-shift-r, which supposedly refreshes the cache and thus fetches the new changes from the server instead of serving the "stale" ones.

This is obviously not ideal, because after a bug fix we'll have to manually ask each person using the app to hit cmd-shift-r to see the fixes/changes.

I found this answer and this answer, the combination of which led me to do this in my firebase.json file (note the "cache-control" and "no-cache" part, I've included the rest for context):

{
  "hosting": {
    "headers": [
      { "source":"/**",
        "headers":
        [
          {
            "key": "Cache-Control",
            "value": "no-cache"
          }
        ]
      }
    ],
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

However, 1) It’s not working, and 2) I worry that this is a bit of an aggressive solution (although I don’t think we currently have a need for caching, so maybe it’s not aggressive).

In sum, it seems that it would be a disaster/quite inconvenient to have to ask all users to hit cmd-shift-r every time we push new changes, and it also seems like we can't be the first people to run into this problem, so I’m wondering if there’s a better way forward.

Thank you very much in advance, Michael King

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
michaelsking1993
  • 441
  • 5
  • 15

0 Answers0