56
votes

I deployed a Firebase app, and made a change to one of the JavaScript files in the project. I re-executed firebase deploy from the project directory, but the files on the site are not updating. When I deploy, the account management shows that an update occurs, but the file remains unchanged. Am I doing something incorrectly? How can I fix/troubleshoot this? Any help would be appreciated.

Thanks

14

14 Answers

115
votes

If the deploy is successful, this is likely a caching issue.

You can try pressing cmd+shift+R (ctrl+shift+R on Windows) to do a hard refresh of the cache.

Try going to the file's URL directly (https://<my-app>.firebapp.com/app.js), and do a hard refresh. You should see it update to what you have locally.

With Chrome, you can have the cache disable when DevTools are open by selecting the "Disable cache" option in the Network tab.

enter image description here

43
votes

make sure you're building any new changes you've made before deploying.

For example if you have an angular 2 application and are using the angular cli type ng build then firebase deploy.

To clear cache press Ctr+F5 or better use incognito Mode for Development. using Incognito Mode for force reload works well for Mobile as well as desktop.

11
votes

I had same issue and I did clear the cache and everything but I still had the same problem, then run

yarn build

Then I could see my latest changes.

10
votes

If you're using React or Vue, do not forget to run the build command like npm run build before running the command firebase deploy

3
votes

Try the same hosting URL in Incognition window, it works me when I go to incognito windows as I have maintained localhost and domain URL in the same window.

Try it, it may be an issue for you too, Thanks

2
votes

refreshing your web- browser

In most Windows and Linux browsers: Hold down Ctrl and press F5.

In Apple Safari: Hold down ⇧ Shift and click the Reload toolbar button.

In Chrome and Firefox for Mac: Hold down both ⌘ Cmd+⇧ Shift and press R.

I hope it helps

Source: https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache

2
votes

To not ever again forget to build before deploying I put this on my package.json:

"scripts": { "build": "node build/build.js && firebase deploy" }

That way I don't have to remember about it. Automate what you can when it comes to deployment.

1
votes

on React(create-react-app)- In case someone gets here for the same reason i did: I had an issue of redeploying the project. the deploy worked at first but when i tried to rebuild(npm run build) and redeploy(firebase delpoy), my site showed a firebase error page(after updating cache with ctrl+shift+r, as suggested here). After a long check i realized i should add rewrites to my firebase.json, so it will look like this:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ {
      "source": "**",
      "destination": "/index.html"
    } ]
  },
  "storage": {
    "rules": "storage.rules"
  }
}
1
votes

Well, I was developing a PWA. I occured the same problem which above steps didn't solve.. So I tried this method, which found to be helpful..

Try deleting the map.js and re-run npm run build twice. Why twice?? Because the first one yields an error but it also rebuilds the map.js file which actually corresponds the changes of the .js files. Finally firebase deploy should give you the working site that you wanted to host. Below is the image of my project files which includes the location of file to be deleted. File to be deleted

1
votes

I faced a similar problem where I build the project, hard reset cache and nothing worked. Then I realised I had layers of cloudflare cdn in front which was giving a cache data. So if you have any CDN in front, disable it while developing.

1
votes

The other way around is deleting the dist/<app_name> folder and running the steps,

  1. firebase init
  2. ng build --prod
  3. firebase deploy again. it worked for me.
1
votes

I was having the same issue with a React App.

Finally realised I hadn't run 'npm run build' therefore everything in the build folder had not been updated which is what Firebase was deploying.

1
votes

I had a similar issue as well. I was using React.js to build a Covid Tracker, and I noticed a bug in my code. After fixing it, I was running firebase deploy but it wasn't doing anything.

Long story short, you need to build the project before deploying it. Running npm run build will create a new optimized version of your project, and then firebase deploy will then go ahead and update your website.

0
votes

Might be good to try reinstalling firebase-tools - after having problems similar to yours, I ran npm i -g firebase-tools and it seemed to fix it up.