[flutter_tools] Ensure service worker starts caching assets since first load (#116833)
* [Flutter_tools] Ensure service worker starts caching assets since the first launch * [flutter_tools] add comment to give some context on self.clients.claim() * [flutter_tools] add comment to give some context on self.clients.claim()
This commit is contained in:
@@ -70,6 +70,8 @@ self.addEventListener("activate", function(event) {
|
||||
await caches.delete(TEMP);
|
||||
// Save the manifest to make future upgrades efficient.
|
||||
await manifestCache.put('manifest', new Response(JSON.stringify(RESOURCES)));
|
||||
// Claim client to enable caching on first launch
|
||||
self.clients.claim();
|
||||
return;
|
||||
}
|
||||
var oldManifest = await manifest.json();
|
||||
@@ -95,6 +97,8 @@ self.addEventListener("activate", function(event) {
|
||||
await caches.delete(TEMP);
|
||||
// Save the manifest to make future upgrades efficient.
|
||||
await manifestCache.put('manifest', new Response(JSON.stringify(RESOURCES)));
|
||||
// Claim client to enable caching on first launch
|
||||
self.clients.claim();
|
||||
return;
|
||||
} catch (err) {
|
||||
// On an unhandled exception the state of the cache cannot be guaranteed.
|
||||
|
||||
Reference in New Issue
Block a user