refresh static method

Future<void> refresh({
  1. List<String> assets = defaultAssets,
  2. bool bustUrl = false,
})

Throws away every browser-side copy of the app and reloads into the deployed build.

Unregisters the service workers, empties CacheStorage, re-downloads assets with a cache-bypassing fetch so the HTTP cache ends up holding the server copy, then reloads. Pass bustUrl when the host serves index.html itself under an immutable policy — it appends a _u query parameter, which changes the URL the user sees.

Implementation

static Future<void> refresh({
  List<String> assets = defaultAssets,
  bool bustUrl = false,
}) async {
  if (!UApp.isWeb) return;
  final String base = UWebBridge.baseUrl();
  await UWebBridge.unregisterServiceWorkers();
  await UWebBridge.clearCaches();
  await UWebBridge.revalidate(<String>[UWebBridge.documentUrl(), for (final String asset in assets) "$base$asset"]);
  UWebBridge.reload(bustUrl ? _bustedUrl() : null);
}