tl;dr - This appears to be a Gatsby liimitation and not a Netlify limitation. I’ll explain in more detail below.
Netlify wouldn’t treat the two data sources differently but it is possible the site’s build code (your code) does. As I’m not familiar with the build code, I’m only able to make guesses about the root cause. I also did some research to help my guesses to be (slightly more) educated guesses.
The cache clearing behavior seems to work because when there is no cached data, the build code always fetches everything again which guarantees the latest versions are used.
It also sounds like that with Contentful, the site build code was able to detect when the local cached version was out of date and would therefore download a more recent version.
What isn’t clear is the exact details about how the site build code detected the differences with Contentful and why this code doesn’t do the same for Firebase.
When researching this I found this Contentful blog post below:
Quoting that page:
Not every content management framework is a candidate for incremental builds. To build incrementally, Gatsby requires tight integration with a CMS to be able to detect changes.
Based on this, it is possible that Gatsby itself doesn’t support incremental builds with Firebase.
I also found this blog post but it is over two years old:
This is talking about Gatsby Cloud specifically but I do think this information applies to incremental builds anywhere. There is says:
To experience the fastest build times, update your site with content from Gatsby Cloud’s first-class CMS integrations. These include Contentful, Sanity, DatoCMS and Cosmic. WordPress and Drupal support are in alpha.
I notice that Firebase isn’t listed there but that is also a more than two year old post so this might be out of date.
Long story short, I cannot find any documentation anywhere about how to get Gatsby incremental builds working with Firebase - working at Netlify or anywhere else. Based on this, it does appear that the explanation here may be that this isn’t supported yet by Gatsby itself.
Please let us know if there are other questions about this.