0

When I open a terminal in my firebase folder with all the dependancies and files etc, and I type 'firebase deploy' into the terminal, all works fine and functions are updated and rules are updated, but the changes to index.html are not pushed to the website. Is there a setting I can check or something that would make it push again?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Ryan
  • 720
  • 1
  • 8
  • 27
  • You haven’t said how you’re checking for the changes. Is it possible that you’re seeing a cached version of the page in your browser? – Aankhen Jun 26 '18 at 11:29
  • This SO Post may interest you: https://stackoverflow.com/questions/48589821/firebase-hosting-how-to-prevent-caching-for-the-index-html-of-an-spa – Renaud Tarnec Jun 26 '18 at 11:32
  • I clear any cookies or cached files and then load my website and then view the source in chrome, and can see that no changes have occurred. – Ryan Jun 26 '18 at 11:41
  • Firebase default cache is 1 hour. If you have not changed that Firebase may continue to serve you the old index.html file for an hour after you deploy it. – abraham Jun 26 '18 at 19:25

2 Answers2

1

Assuming you are hosting the index.html in addition to function deployments: Is the index.html file in the folder specified under "hosting": { and not in the ignored files?

You can also run firebase deploy --only hosting to only deploy hosting related changes.

Since the file is in your root directory you need to set that as the public directory for firebase

{
  "hosting": {
    "public": "/",
    ...
  }
}
abraham
  • 46,583
  • 10
  • 100
  • 152
anoff
  • 63
  • 7
  • [This is my firebase.json](https://ibb.co/kBrSX8) My index.html file is stored directly in the folder (no subfolders or anything) – Ryan Jun 26 '18 at 11:32
  • The issue with modifying the default to host out of root is that your `firestore.rules` and a bunch of other non-public files are gonna be viewable on the web, unless you go in and exclude them from being hosted. ...basically - don't do it. It's unnecessary over-complication. ...keep it simple. – Ronnie Royston Jun 27 '18 at 02:04
  • 1
    I have to agree with @RonRoyston. I think you would do yourself a favor and put that index in a separate folder, as stupid as it may sound for a single file. My answer was simply trying to be as close to the question as possible. – anoff Jun 27 '18 at 20:08
0

Put your index.html file in the /public folder, which is what is being served on Firebase Hosting. This is the way you want it. You don't want to publish files at the root directory.

Ronnie Royston
  • 16,778
  • 6
  • 77
  • 91
  • I thought there were 2 different index.html files, one in public and one in root. Am I mistaken? Should my main one be the one in public? – Ryan Jun 26 '18 at 23:12
  • the one in root was put there when you created your `new HTML5 project` in your IDE (most likely). No, you only want the one `index.html` in `/public`. Note, it's perfectly valid to have additional `index.html` in subfolders, say for example `/public/articles/index.html` will display at `//your-domain/articles.html` but no, the one in the root directory can be destroyed/deleted, based on your firebase config file. – Ronnie Royston Jun 27 '18 at 02:01