Web: Default Service Worker implementation getting removed.

717 views
Skip to first unread message

David Iglesias Teixeira

unread,
Oct 17, 2024, 11:53:34 AM10/17/24
to Flutter Public Announcements (flutter-announce)

TL;DR: Flutter web's default Service Worker is going away. See the design document for more details: https://flutter.dev/go/web-cleanup-service-worker 


The problem


Flutter's current service worker only offers one of the possible service worker strategies, but our users have repeatedly requested more flexibility (like custom cache-busting schemes, proxy server support, user prompts for updates, etc...)


Since there can only be one service worker per web application, we have decided to not get in the way and allow users to craft and set their own service worker implementation, instead of defaulting to something that users end up "fighting against", working around, or completely removing.


Flutter web is changing the default implementation of the Flutter service worker to do one last "cleanup", and then will stop generating a default service worker altogether.


What is exactly happening?


1. The default Flutter web service worker will change from the current implementation to a "cleanup" service worker. This cleanup service worker will update the current default one, and remove itself from end users' browsers.

2. In a later release, Flutter will stop generating the default flutter_service_worker.js file, and flutter.js will stop attempting to install any service worker.


For more details, check the design doc: https://flutter.dev/go/web-cleanup-service-worker 


When?


We estimate the change will happen in the first stable release of 2025, but master and beta will be affected earlier.


Will apps break? How to prepare for this change?


In most use cases, this change will be completely transparent. Your app will stop using the Service Worker-managed caches, and start using the default browser cache. After rebuilding a Flutter web application that uses the default service worker, the new one will be picked up and deployed to end users.


Post-processing of the service worker will most likely break (hence this announcement), but the build/web directory can still be traversed to compile the list of files that will be deployed, which can then be used to generate any custom service worker, specific to your assets.


How to use a service worker moving forward?


Flutter web app developers can modify their index.html (or their flutter_bootstrap.js) to inject their custom service worker. See the Service Worker API.


We can't wait to see what service worker integrations the Flutter web community comes up with!


Reply all
Reply to author
Forward
0 new messages