Repository navigation
Description
Document Link
What problem are you solving?
The current default service worker implementation is one of (several) approaches that can be used by Flutter web, however it's not a good fit for all use-cases.
This confuses users when it doesn't behave as they expect.
Having a default service worker implementation sends the message that it is necessary or recommended by Flutter web to function correctly, but that is not the case.
This design doc discusses how the current implementation of flutter_service_worker.js is going to be phased out (TL;DR: with a cleanup service worker for those currently using the default one), and how the flutter tools and flutter.js will eventually stop generating (or loading) a default service worker, allowing web app developers to do what's best for their specific apps.
Activity
slavap commentedon Oct 17, 2024
@ditman
the best for any web app is to have PWA "just working". If someone for some reason wants "custom PWA with different approach", let them do it, but for others 90% of "lazy" developers - the default implementation of "one of (several) approaches" is absolutely fine, just make it "dumb" and reliable as AK-47.
As you mentioned in the doc: "Most of the web frameworks that provide a way to serve a service worker, also offer a way to clean it up, like Angular or Vite."
Now ask yourself - why do these frameworks provide PWA functionality, but you are proposing the opposite ??? I.e. we cannot provide reliable default PWA support, so let's just eliminate it completely, and pray that the community somehow solves it instead of us.
uldall commentedon Oct 17, 2024
@slavap I do not believe PWA's require a service worker nowadays. See https://web.dev/articles/install-criteria#criteria.
slavap commentedon Oct 18, 2024
@uldall if that is correct and PWA could work without service worker - then that has to be clearly explained in the document.
ditman commentedon Oct 18, 2024
@slavap thanks for your message, feedback is always appreciated! (you should also be able to comment on the google doc itself if you want to!)
To me, the biggest problem that the current default service worker has is that people think that it is mandatory, when in reality, it isn't.
For most of Flutter web developers, the standard browser cache will work as expected, and they'll have a more familiar development and deployment experience: "deploy-full page reload-new app". (The rest 1% is providing their own service worker implementation anyway to achieve whatever extra goals they have.)
I'm not opposed to generating service workers with Flutter web, but I think we should:
flutter_service_worker.js, instead of doing it automatically?)fluttertooling play nicer with other build systemsI don't know how to get to that future yet! Maybe it can be done as a package:build, or using the upcoming Native assets feature, but I think it's better to cleanup and then try again.
In the meantime, users who really want a service worker can build their own, without worrying that the Flutter build is going to step on their toes.
PS: There's cool reads about "PWA", service workers and related stuff here:
PPS: We can update the document to make any of it clearer, feel free to leave inline comments there!
slavap commentedon Oct 18, 2024
@ditman
This sounds like a totally right idea to me, integrating with "battle-tested technology" and not reinventing the wheel is always great.
jezell commentedon Oct 18, 2024
Love this change!
lukepighetti commentedon Oct 18, 2024
I do think it's reasonable for users to expect Flutter to provide a sane default PWA experience (like every other popular web framework).
But IIRC that is blocked right now by issues like hotfixes not working as expected.
So any short term feature losses that resolve the big issues deploying flutter web are welcome... as long as the vision for a sane default PWA experience is retained.
yjbanov commentedon Oct 18, 2024
@ditman Can you please clarify in the doc what the plan is for the
manifest.jsonfile?rayliverified commentedon Oct 19, 2024
Does this remove cache busting? I have a concern that this will make updating Flutter Web apps successfully even harder.
One issue that's popped up with Flutter Wasm builds is that something gets cached by the browser and stuck so newer builds often fail. New builds try to reference some symbols that are different from old builds.
Edit: We may have variables that crash in Wasm due to unsupported typing or casting, so it could be unrelated.
Refreshing the page does not fix. Clearing cache doesn't fix either. The only fix is "Clear application data" in dev tools.

How does this impact the updating web apps workflow?
One thing I can see it helping is it would let me run my own service worker to clear the application data when I detect a newer version of my app from the server. But that wouldn't be out of the box behavior. So what would the default behavior and strategy be?
Ideally, Flutter Web developers can publish a new version, the new version runs and works.
That's not what is happening now. Would that be a goal of this change?
ditman commentedon Oct 21, 2024
@rayliverified The current implementation attempts to aggressively cache and pre-fetch the
assetsof your app; that will stop happening. The new default behavior will be "remove the default service worker, if it's installed.", so we can help "clean up" web apps that don't care about the service worker and just take "the default". Later, we will stop emitting a service worker completely so you can install your own.Yes, this change should move your app to using the default browser cache (that you can control via your CDN configuration), rather than having our own implementation on top of that. This should make your update-after-deployment experience much more straightforward, and was specifically one of the things that motivated this change!
56 remaining items
deploy: follow Flutter's own recommended cache headers for the static…
deploy: nothing Flutter emits is hashed, so stop marking it immutable (…
Sluta registrera en service worker – fixar hemskärms-PWA:n som hängde
Run 411: Update-Erkennung auf version.json statt Service Worker umges…
feat: add a real offline-capable service worker
fix: disable Flutter's default service worker in the deploy build
feat: add a real offline-capable service worker (Flutter's own is now…
[web] Self-cleaning service worker (#176834)
[web] Deprecate --pwa-strategy (#177613)
[web] Remove service worker loader and --pwa-strategy (flutter#194785)
docs: cite flutter/flutter#156910 and the #194785 migration path for …
github-actions commentedon Nov 12, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.