Support offline mode after the first Playground page load #1643
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A set of bugfixes and enhancements for PR 1535 – Cache Playground assets to enable offline support:
Offline mode after a single page load
Without this PR:
When the service worker is first registered, it does not yet handle the network requests triggered by the page that registered it. Files fetched on the initial Playground load, like
wordpress-static.zip
, are not cached. This means the offline mode won't work yet. You need to do a full page reload, wait for another round offetch()
-es, and only then you get cached assets and a functional offline mode.With this PR:
Service Worker calls
self.clients.claim()
to start controlling the Playground page when the service worker is initially registered. Static assets are cached and offline mode works after the very first page load.Backfill static assets before the first paint
wordpress-static.zip
is cached, it will be extracted during Playground boot.Other smaller changes
function myFn(){}
instead of instance methods (myFn = () => {}
)cc @bgrgicak