Flutter web deployed with firebase hosting does not respect refresh in Safari

731

In more recent versions, they are appending a random hash on every build to the flutter_service_worker.js URL so it should break the cache and refresh properly.

Share:
731
pjotr_dolphin
Author by

pjotr_dolphin

Lead of Dolphin KISS Finland/Hong Kong/Romania with around 20 employees. Background from physics, mathematics and technology. Heading development of analysis/learning software. Lovely son and girlfriend... Golf freak with career low 2.3 in handicap...

Updated on December 18, 2022

Comments

  • pjotr_dolphin
    pjotr_dolphin over 1 year

    I have a Flutter web app that is deployed on Firebase Hosting. When deploying a new version Safari does not pick up the new version even when doing refresh. I assume this is due to the installed service worker, that will serve the old content. How can one bypass this problem? I know that a hard refresh solves the problem, but that is not a good solution as we cannot expect the users to know to do that.

    One alternative that requires client code, would be that I track the current version of the app that is currently loaded, and if that change I create "New version available" screen when I detect that a new version is available, and perform a location.reload(true) call from the client to bypass cache and get the new service worker installed.

    Any other options?

    • Daniel Eberl
      Daniel Eberl almost 4 years
      I have the same problem with react, even without a service worker running. Did you find a solution for this?
    • hiashutoshsingh
      hiashutoshsingh over 3 years
      did you increase the version in index file of web folder of your flutter project ? I have the same issue i just increased the version of JS file in which is in index.html in web folder.
  • pjotr_dolphin
    pjotr_dolphin over 3 years
    Yes, I can confirm this is now a non-problem :)