Workbox v4.0.0-rc.0
Pre-release
Pre-release
The latest RC release of Workbox v4 includes the following developer-visible changes, in addition to all the changes from the previous pre-releases.
🎉 What's New?
workbox-window
- The addition of a
scriptVersion
option to theWorkbox
constructor in beta.2. has been reverted, as well as the change to the function signature. TheWorkbox
function signature is now the same as it was in beta.1 [#1876]:
new Workbox(scriptURL, registerOptions);
workbox-google-analytics
- If you use Google Tag Manager (GTM) to load Google Analytics on your site, Workbox will now cache the
gtm.js
library so it will work offline as well [#1869].
workbox-expiration
and workbox-broadcast-update
The npm names of these two packages has change to reflect their browser namespace.
workbox-cache-expiration
➡️workbox-expiration
workbox-broadcast-cache-update
➡️workbox-broadcast-update
This change only affects developers who bundle their service worker from npm dependencies. Developers who load Workbox using workbox-sw
should not have to change their code. [#1879]
⚠️ Breaking Changes
workbox-expiration
- The underlying IndexedDB data model for cached entry metadata has changed from using IndexedDB database names that match the cache name (one database per cache name) to a single database named
workbox-expiration
. If you had code that was manually inspected this metadata, you'll need to update it to check the new database [#1883].
🐛 What's Fixed?
workbox-window
workbox-window
scripts were not being copied when using thecopyLibraries
inworkbox-build
andworkbox-cli
. This has been fixed [#1871].
workbox-expiration
- The
workbox-expiration
documentation states that themaxAgeSeconds
option will expire entires based on the time they were last accessed. But due to a bug in the logic, it would actually expire entries based on the time they were originally cached. This has been fixed, and the behavior now matches the documentation [#1883].
workbox-build
- After changes to
workbox-precaching
in beta.1, using thenavigationFallback
option inworkbox-build
wouldn't work if your fallback URL had precach metadata added to it. This has been fixed inworkbox-build
, but anyone usingworkbox.routing.registerNavigationRoute()
and passing it a precached URL will likely need to update their code to useworkbox.precaching.getCacheKeyForURL()
as well:
// This won't work anymore.
workbox.routing.registerNavigationRoute(myPrecachedURL);
// Instead, do this:
workbox.routing.registerNavigationRoute(
workbox.precaching.getCacheKeyForURL(myPrecachedURL)
);