This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
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.
This PR contains the following updates:
3.0.0-alpha.5
->3.6.3
Release Notes
googlechrome/workbox
v3.6.3
Compare Source
🐛 What's Fixed?
This release fixes an issue (#1677) that several users have reported, triggered by precaching a URL that returns a 30x redirect to another URL. For instance, having
'/index.html'
listed in your precache manifest can trigger this issue, if your web server responds to requests for'/index.html
' with a 301 redirect to the destination URL'/'
. When the issue manifests itself, the final, redirect content ends up being served with an incorrectContent-Type:
response header, which can in turn lead problems displaying that cached content.If you do use 30x redirects for some of your URLs, we recommend updating to this latest release of Workbox.
In order to "clear out" the problematic content that was previously precached with an incorrect
Content-Type
, after updating Workbox, you can deploy a small change to URLs that you know are affected (i.e. make any change to your'/index.html
' file, if that's being fulfilled with a 30x redirect).It's also possible to force all previously cached entries to be precached again by changing the
cacheId
option in "generate SW" mode, or by includingin your service worker source file in "inject manifest" mode.
📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.6.2
Compare Source
🎉 What's New?
This release contains a fix for a missing
dependency
entry inworkbox-webpack-plugin
'spackage.json
. Thanks to @arcanis for contributing the fix in #1667!There are no functional changes in this release.
📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.6.1
Compare Source
🎉 What's New?
Added the
disable()
method toworkbox.navigationPreload
workbox.navigationPreload
provides anenable()
method to enable navigation preload, but it did not provide a way to disable it (without invoking the underlying service worker APIs). Now developers can callworkbox.navigationPreload.disable()
to disable navigation preload. (#1651)The
method
option can now be used for runtime caching viagenerateSW()
method
option from being used by runtime caching configuration ingenerateSW()
. Thanks to @chrisdns, this has been fixed! (#1638)Bug fixes and ergonomic improvements
workbox.expiration.Plugin
withpurgeOnQuotaError
set totrue
would result in an error. Thanks to @salmoro for discovering and fixing the issue! (#1643).event
that triggered them, so developers writing custom plugins could not access any information about the event in those callback. Now all plugin callback are passed the event object (when available). (#1640)workbox-streams
package'sstrategy()
method is exposed on the browser build ofworkbox.streams
that gets loaded by theworkbox-sw
loader, but it wasn't exported by the module in a way that was accessible to module bundlers. Now it's possible to import{strategy}
fromworkbox-streams/strategy.mjs
. (#1635).📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.5.0
Compare Source
🎉 What's New?
More customization when generating a service worker
Developers who use Workbox to generate their service worker (using the CLI, Node interface, or webpack plugin) can now take advantage of some additional options:
Setting
offlineGoogleAnalytics: true
will automatically add code to initialize Workbox's offline Google Analytics support in the generated service worker.Both
fetchOptions
andmatchOptions
can now be used when configuring aruntimeCaching
route, and those values will be passed through when constructing the corresponding Workbox caching strategy. Many thanks to @peterjosling for contributing this in #1608.Using a custom plugin within a
runtimeCaching
route is now possible, thanks to enhancements made by @tsirlucas in #1598.Here's a snippet of Workbox's build configuration, showing off all of the new features:
Support for the
PATCH
method in Workbox's routerDevelopers who need to match HTTP
PATCH
requests using Workbox's router can now do so, thanks to @kevin-brotcke's change in #1618.Note that non-
GET
requests can't be added to a cache, so this is most useful when used alongside a network-only strategy configured with the Workbox background sync plugin, in order to retry failedPATCH
requests once the network becomes available.workbox.core.registerQuotaErrorCallback
is now publicly visibleDue to a scoping error, the
workbox.core.registerQuotaErrorCallback()
function was previously not exposed. This is now public, matching the documented interface. Thanks to @Tronil for pointing out this discrepancy in #1616.📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.4.1
Compare Source
🎉 What's New?
Support for navigation preload
The new
workbox-navigation-preload
module provides a simple way of opting-in to navigation preload on browsers that support the feature. When run on browsers which lack navigation preload support, using the module will have no effect.To take advantage of this new feature, you should make sure to set up a route that will match navigation requests, and uses a strategy that makes use of the response from the network, like
networkFirst
,staleWhileRevalidate
,networkOnly
, orcacheFirst
.Developers who are already handling navigations by responding with precached HTML (potentially configured with an App Shell fallback) do not need to enable navigation preload! This feature is intended to reduce navigation latency for developers who can't precache their HTML, but still want to use Workbox to handle caching of other assets on their sites.
workbox.strategies
now supports using customCacheQueryOptions
Developers who want to customize how
workbox.strategies
performs its internal cache lookups can now pass in amatchOptions
parameter to use as theCacheQueryOptions
whencache.match()
is called under the hood.Many thanks to @torbs for contributing this in https://github.com/GoogleChrome/workbox/pull/1561!
🐛 What's Fixed?
workbox.expiration.Plugin
from working as intended in Microsoft Edge. Thanks to @josephliccini for contributing https://github.com/GoogleChrome/workbox/pull/1510!📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.3.1
Compare Source
🐛 What's Fixed?
workbox.core.registerQuotaExceededCallback
symbol [#1553] (Thanks to @xe21500 and others for reporting)Cache-Control
on CDN hosting [#1539]workbox.setConfig()
docs after calling workbox copyLibraries [#1553]📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.3.0
Compare Source
🎉 What's New?
Cache maintenance improvements
Two new features are available to help developers deal with cache maintenance, and in particular, storage quota errors.
First, a new
deleteCacheAndMetadata()
method has been added to theworkbox.expiration.Plugin
class. This can be called manually, and it will delete all entries in the cache that the plugin is associated with, as well as clear out all metadata related to cache expiration for the plugin instance. While it's always been possible to explicitly callcaches.delete(<cacheName>)
, that would not clear out any expiration metadata, and could lead to unexpected expiration behavior the next time the cache was recreated. (#1500)Next, a new
purgeOnQuotaError
parameter can be passed in when configuringworkbox.expiration.Plugin
. It defaults tofalse
, but if set totrue
, you can opt-in to clearing all entries in a given cache (via a calldeleteCacheAndMetadata()
made automatically) whenever a quota errors occurs anywhere in Workbox. This allows you to mark certain runtime caches as being "safe" for automatic cleanup, clearing up room for your web app's more critical cache storage usage. (#1505)Opting-in to this behavior explicitly in your service worker looks like:
When using
generateSW
in a build tool along with theruntimeCaching
option, you can achieve something similar with the following configuration:Automatic cache cleanup is still in its early phases, and we encourage developers who use runtime caching (especially of opaque resources, which can lead to high quota usage) to give the new functionality a try, and provide feedback.
The
fetchDidFail
lifecycle event is passed a newerror
parameterDevelopers using the
fetchDidFail
lifecycle event to write plugins which respond to a failed network request now have access to the original underlying exception, via theerror
property of the callback's parameter. (#1486)More information is available in our Custom Plugins guide.
gzip'ed CDN assets
Users of the CDN copies of the Workbox runtime libraries will now benefit from
Content-Encoding: gzip
support, leading to smaller initial downloads. (#1523)🐛 What's Fixed?
ReadableStream
is functional, and trigger non-streamed fallback logic when it's not, to workaround an issue with the current Edge build andworkbox-streams
. (#1476)copyWorkboxLibraries
. The new replacement logic is more robust when your destination path includes the string'prod'
. (#1488)workbox-webpack-plugin
integration tests are now run againstwebpack
v4, instead of v3. (webpack
v3 still remains supported; this only affects the test suite.) (#1492)📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.2.0
Compare Source
🎉 What's New?
A new workbox-streams module
The
workbox-streams
module provides an easy-to-use wrapper on top of the Streams API, allowing you to create a streaming response from a sequence of multiple sources.The new module offers a convenience
workbox.streams.strategy()
method that can be used as a strategy in aworkbox.routing
configuration, allowing you to respond to matching requests with a stream:For more information and usage examples, please see the documentation and the live demo. (#1439)
Improved resiliency during unexpected cache misses
If a cache entry that would normally be used to fulfill a request is unexpectedly missing,
workbox.routing.registerNavigationRoute()
will now fall back to the network to obtain that response. Previously, this would lead to a failed navigation. (#1460)precacheAndRoute() now accepts options in injectManifest mode
Previously, when using
injectManifest
mode withworkbox-build
orworkbox-cli
, the default regular expression would look forprecacheAndRoute([])
inside of yourswSrc
file, and use that[]
as the point at which to inject the manifest.We've relaxed the default regular expression so that, in addition to supporting the previous usage, it will also work with
precacheAndRoute([], {...})
, where{...}
are the options that you might want to pass in to configure precaching behavior. (#1459)Changes to swSrc will trigger a new webpack dev server build
When using
workbox-webpack-plugin
'sInjectManifest
mode inside of awebpack
dev server environment, making updates to theswSrc
file will now trigger a fresh build. Thanks to @green-arrow for the contribution! (#1432)🐛 What's Fixed?
workbox.strategies.staleWhileRevalidate()
andworkbox.strategies.cacheFirst()
in the Samsung Internet browser. (#1457)compiler.inputFileSystem
API when working with thewebpack
filesystem. Thanks to @DorianGrey for the contribution! (#1437)📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.1.0
Compare Source
🎉 What's New?
workbox-webpack-plugin offers more control over paths and filenames
New
precacheManifestFilename
andimportsDirectory
options were added to the webpack plugins, giving developers more control over where their generated files are saved.When
importWorkboxFrom: 'local'
andoutput.publicPath
is configured, theoutput.publicPath
value will be prepended to themodulePathPrefix
used to determine where the Workbox libraries are dynamically loaded from. This amounts to a change in the previous behavior, but based on developer expectation, the previous behavior was considered a bug.See #1403 for more details about the change, and the documentation for the complete list of configuration options.
New makeRequest() method added to classes under workbox.strategies
Most developers will use one of Workbox's strategies as part of a router configuration. This setup makes it easy to automatically respond to specific
fetch
events with a response obtained from the strategy.However, there are situations where making a request using a strategy outside of the standard router setup could be useful. For instance, you might be implementing your own routing logic, or you might want to create a composite response that contains information from multiple smaller responses, stitched together. There are also situations where you'd normally call
fetch()
directly, but you'd like to take advantage of the plugin integration offered by a strategy class.See #1408 for more details.
🐛 What's Fixed?
date
header set (#1422) (Thanks to @matthewjmay for identifying the issue and contributing the fix!)📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.0.1
Compare Source
🎉 What's New?
swDest
paths (#1370 )🐛 What's Fixed?
workbox-precaching
setup for install and activate events. (#1367)workbox-precaching
had an intermittent issue where the temporary cache was dropping requests (#1368)📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/
v3.0.0
Compare Source
Overview of Workbox V3
Workbox v3 has been focused on reducing the size of the library, while lowering the friction for usage. This has been accomplished thanks to a significant refactoring of the existing codebase. We believe the migration process for most users should be minimal, taking a few hours.
Developers are encouraged to view our documentation, including a migration guide for moving from either Workbox v2 or from
sw-precache
/sw-toolbox
to Workbox v3.Many thanks to @beatrizdemiguelperez, @raejin, @goldhand for contributing code for the v3 release, and to all the members of the community who tested and gave feedback during our alpha and beta periods.
🥅 High-level Goals for v3
Minimize the size of Workbox
The size of the Workbox libraries has been reduced. Instead of opting everyone in to a monolithic bundle, only code for the features you use will be imported at runtime.
Workbox has official CDN support
We provide a Google Cloud Storage-based CDN of the Workbox runtime libraries, making it easier to get up and running with Workbox.
Improved webpack Plugin
workbox-webpack-plugin
integrates more closely with the webpack build process, allowing for a zero-config use case when you want to precache all the assets in the build pipeline.Achieving these goals, and cleaning up some aspects of the previous interface that felt awkward or led to antipatterns, required introducing a number of breaking changes in the v3 release.
Better Debugging and Logs
The debugging and logging experience has been vastly improved. Debug logs are enabled by default whenever Workbox is used from a
localhost
origin and all logging and assertions are stripped from the production builds🎉 New Functionality
workbox-build
globFollow
andglobStrict
added toworkbox-build
. This means symbolic links will be followed when searching for files and any errors discovered byglob
will now throw. (#1104)workbox-cli
--injectManifest
in theworkbox-cli
wizard. (#1171)workbox-precaching
workbox-precaching
supports two new configuration options,cleanUrls
andurlManipulation
. By defaultcleanUrls
is true and will append.html
to a reqest when looking for a precache hit (i.e./about
will check for/about.html
).urlManipulation
can be a function enabling you to express a mapping between the server-side URL and the underlying local file. (#1154)If a precached request is not in the cache, we fallback to the network. (#1302)
Precaching will store requests in a temporary cache on install and copy these requests to final cache during the activate step. (#1316)
The precaching IndexedDB name is now derived from the cache name - allowing multiple precaches on a single origin. (#1346)
workbox-strategies
workbox-webpack-plugin
Adds support for webpack v4, while retaining support for webpack v3. (#1275)
workbox-webpack-plugin
now supports{test, include, exclude}
-style filtering, providing an additional way of controlling which assets are included in the precache manifest. By default, assets matching/\.map$/
or/^manifest\.js(?:on)$/
are excluded. (#1149)Build Configuration
The following changes affect the behavior of all of our build tools (
workbox-build
,workbox-cli
,workbox-webpack-plugin
), which share a common set of configuration options.The
'fastest'
handler name was previously valid, and treated as an alias for'staleWhileRevalidate'
, when configuringruntimeCaching
. It's no longer valid, and developers should switch to using'staleWhileRevalidate'
directly. (https://github.com/GoogleChrome/workbox/issues/915)Several
runtimeCaching.options
property names have been updated, and additional parameter validation is in place that will cause a build to fail if an invalid configuration is used. See the documentation forruntimeCaching
for a list of currently supported options. (https://github.com/GoogleChrome/workbox/issues/1096)A new
importWorkboxFrom
option can be used to determine where the Workbox libraries are read from: the CDN, locally, or from a custom bundle (when using webpack).workbox-background-sync
There are significant changes to the API surface in v3. Developers should consult the documentation for current guidance. (https://github.com/GoogleChrome/workbox/issues/868)
The
maxRetentionTime
configuration option is now interpreted as a number of minutes, rather than milliseconds. (#1268)The tag name is now used when responding to a sync event. (#1280)
workbox-build
The default destination of a service worker for the CLI has changed from 'build/' to the location of the
globDirectory
(i.e. the directory searched for files to precache). (#1105)The
getFileManifestEntries()
function has been renamed togetManifest()
, and the promise returned now includes additional information about the URLs which are precached.The
generateFileManifest()
function has been removed. Developers are encouraged to callgetManifest()
instead, and use its response to write data to disk in the appropriate format.workbox-cache-expiration
The plugin API has stayed the same, however there are significant API changes impacting developers who use it as a standalone class. Consult the documentation for the updated API surface. (https://github.com/GoogleChrome/workbox/issues/920)
workbox-cache-expiration now throws an error if you attempt to expire entries on the default runtime cache (i.e. the shared cache used by all strategies by default). (#1079)
workbox-cli
The set of command line options, and the way of reading in stored configuration, have all changed. Developers should consult the documentation or run the CLI with the
--help
flag for guidance. (https://github.com/GoogleChrome/workbox/issues/865)Support for the
workbox-cli
alias for the binary script has been removed. The binary can now only be accessed asworkbox
. (https://github.com/GoogleChrome/workbox/issues/730)workbox-google-analytics
workbox-background-sync
library, and therefore rely on the Background Sync API. (https://github.com/GoogleChrome/workbox/issues/244)workbox-precaching
The
precache()
method previously performed both the cache modifications and set up routing to serve cached entries. Now,precache()
only modifies cache entries, and a new method,addRoute()
, has been exposed to register a route to serve those cached responses. Developers who want the previous, two-in-one functionality can switch to callingprecacheAndRoute()
. This enables more developer flexibility. (https://github.com/GoogleChrome/workbox/issues/886).workbox-broadcast-update
will no longer be automatically configured to announce cache updates for precached assets. To get this behavior, you can add the plugin manually. (https://github.com/GoogleChrome/workbox/issues/1073)workbox-routing
The
Router
will now evaluateRoute
s in a first-registered-wins order. This is the opposite order ofRoute
evaluation that was used in v2, where the last-registeredRoute
would be given precedence. (https://github.com/GoogleChrome/workbox/issues/845)The
ExpressRoute
class, and support for "Express-style" wildcards have been removed. This reduces the size ofworkbox-routing
considerably. Strings used as the first parameter toworkbox.routing.registerRoute()
will now be treated as exact matches. Wildcard or partial matches should be handled byRegExp
s—using anyRegExp
that matches against part or all of the request URL can trigger a route. (https://github.com/GoogleChrome/workbox/issues/1012)The
addFetchListener()
helper method of theRouter
class has been removed. Developers can either add their ownfetch
handler explicitly, or use the interface provided byworkbox.routing
, which will implicitly create afetch
handler for them. (https://github.com/GoogleChrome/workbox/issues/914)The
registerRoutes()
andunregisterRoutes()
methods were removed. The versions of those methods that operate on a singleRoute
were not changed, and developers who need to register or unregister multiple routes at once should make a series of calls toregisterRoute()
orunregisterRoute()
instead. (https://github.com/GoogleChrome/workbox/issues/856)workbox-strategies (formerly know as workbox-runtime-caching)
The
workbox-runtime-caching
module is now officially known asworkbox-strategies
, and has been published onnpm
under its new name. (https://github.com/GoogleChrome/workbox/issues/1045)The syntax for specifying plugins when configuring a strategy has changed. Each plugin needs to be explicitly listed in the
plugins
property of the strategy's configuration. (https://github.com/GoogleChrome/workbox/issues/1071)Defining a strategy that applies to the default cache name and which uses cache expiration is no longer supported. When configuring cache expiration, you must also configure a specific cache name. (https://github.com/GoogleChrome/workbox/issues/1014)
The
cacheWillMatch
lifecycle method has been renamed tocachedResponseWillBeUsed
. This should not be a visible change for developers unless they wrote their own plugins that reacted tocacheWillMatch
. (https://github.com/GoogleChrome/workbox/issues/713)workbox-sw
The
handleFetch
option has been removed. (https://github.com/GoogleChrome/workbox/issues/1002)skipWaiting
andclientsClaim
are no longer options passed to theWorkboxSW
constructor. Instead, they have been changed to methods of the same name that could be called on theworkbox
namespace. (https://github.com/GoogleChrome/workbox/issues/853)workbox-webpack-plugin
v3.0.0-beta.2
Compare Source
🎉 What's New?
🐛 What's Fixed?
broadcastUpdate
in workbox-build config (#1334)📖 Learn More
Check out our docs @ developers.google.com/web/tools/workbox/next/
v3.0.0-beta.1
Compare Source
🎉 What's New?
broadcastUpdate
option instead ofbroadcastCacheUpdate
(#1292)same-origin
to precache URLS (#1293)importWorkboxFrom: 'local'
in the injectManifest Webpack Plugin (#1290)cache-control
header for the service worker is not set tono-cache
ormax-age=0
(#1317)🐛 What's Fixed?
addRequest
in background-sync now asserts you are passing in aRequest
object (#1305)importScripts
in workbox-build (#1327)v3.0.0-beta.0
Compare Source
The first beta release of Workbox v3 includes additional integration tests and demos, as well as the following developer-visible changes from the previous alpha release.
🎉 What's New?
maxRetentionTime
setting is now interpreted as a number of minutes, rather than milliseconds (#1268)🐛 What's Fixed?
--help
message when there are no params passed toworkbox-cli
. (#1242)workbox-cli
. (#1246).map
when suggesting extensions to precache in theworkbox-cli
wizard. (#1255)v3.0.0-alpha.6
Compare Source
The latest alpha release of Workbox includes some project health improvements, as well as the following developer-visible changes from the previous alpha release.
🎉 What's New?
🐛 What's Fixed?
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.