71

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

user3660665
  • 721
  • 1
  • 5
  • 5

16 Answers16

137

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>.web.app/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

David East
  • 31,526
  • 6
  • 67
  • 82
  • 1
    @SA__, are you interested in using Firebase Hosting? If so, I can help. – David East Dec 11 '15 at 04:58
  • Thanks! This worked. I'm a little embarrassed I didn't think of this myself... :) – user3660665 Dec 12 '15 at 19:03
  • @DavidEast, I have the same problem, where Firebase deploy is not updating JS file, I went to _https://.firebapp.com/app.js_ as suggested, to notice that it has not been updated to what I have locally. – SpaceX Mar 16 '16 at 01:05
  • Had a hiccup in hosting. It should be good now! Let me know if you're still having issues. – David East Mar 16 '16 at 01:35
  • I will now use hard refresh bigly. Thank you. – Leo Folsom Jun 12 '17 at 15:47
  • 7
    @DavidEast while this is helpful for debugging/developing. Some of my users see the old version. How can I force their browser to load the new version? Thanks! – bernatfortet Aug 23 '17 at 02:30
  • I have the same problem but clearing cash and hard cash empty didn't worked! – Mehrnoosh Dec 18 '17 at 06:04
  • THANK YOU, this drove me crazy – kumail Jun 07 '18 at 03:00
  • 4
    @user3660665 you did the right thing in calling for help. 4 years later, it helped me tremendously as I made the same mistake. Because without your question I would not have found the answer. So thank you. Besides, a lot of humiliation is a bit of humility - good for the soul ! Let's continue to fail toward perfection... – Titou Feb 21 '19 at 12:26
  • same here 4 years later! But for some reason https://.firebapp.com/app.js showed nothing!? Any idea which url could enable me to view my public folder on Firebase Hosting? – Yo Apps Nov 12 '19 at 14:44
  • 3
    This is not the right answer if the problem is with a client (that shouldn't need to do a clean to see changes). Does anybody know how to fix that? – Gustavo Contreiras Sep 12 '20 at 03:06
  • 1
    If by client you mean another person at another computer, the problem is with how long you are setting the browser cache for in the `Cache-Control` header. Firebase sets a 5 minute cache by default so the site will update after that time period if the client does not refresh themselves. Make sure you are not setting it for a long period of time. If that does not fix it then you have a different problem, such as not deploying correctly or you have an improperly configured service worker that's aggressively caching the page. – David East Sep 15 '20 at 15:41
60

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.

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
aheigins
  • 2,574
  • 3
  • 19
  • 26
24

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

lorem_impus
  • 320
  • 3
  • 9
15

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.

dhilt
  • 18,707
  • 8
  • 70
  • 85
Mehrnoosh
  • 879
  • 2
  • 12
  • 27
4

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.

jean d'arme
  • 4,033
  • 6
  • 35
  • 70
4

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.

3

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

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

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

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

Community
  • 1
  • 1
Abhinav Kinagi
  • 3,653
  • 2
  • 27
  • 43
1

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"
  }
}
orish
  • 155
  • 2
  • 12
1

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

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.

0

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.

0

I also have the same issue with HUGO website hosting on firebase app.and the issue solved successfully,can be your reference.

firstly need delete the public file locally, can then re build site use

HUGO -D

now public file rebuilt.

then deploy again.

Firebase deploy

I think why the firebase no updated is you only update the content, but it can not update the pubic file automatically, you need rebuild public file again.

Yan Zhang
  • 341
  • 1
  • 6
  • 15
0

Might be late but It may help somebody

In your flutter project Delete web platform folder

open command prompt and run

flutter create . --platforms web this will create web folder again run

again build for web

flutter build web

to run web app locally you need to install lite-server run

npm install -g lite-server

after successful install from your project directory run

cd build/web && lite-server

It will run you web app locally on your machine So before deploying to the firebase hosting do some more changes in firebase.json and index.html file. for more help refer article

After that in your project directory do the changes in file firebase.json :

"hosting": {
"site" : "statepcs3",
"public": "build/web",
"ignore": [
  "firebase.json",
  "**/.*",
  "**/node_modules/**"
],
"headers": [

  {
    "source": "**",
    "headers": [
      {
        "key": "Cache-Control",
        "value": "no-cache"
      }
    ]
  }

]

}

Anks
  • 11
  • 2