4.0.0
What's New?
The 4.0.0
release brings with it a number of exciting and substantial changes. While the configuration options used in earlier releases should be compatible with 4.0.0
, the generated service worker will use a different underlying caching technique that isn't compatible with older caches. After upgrading, your users will end up repopulating their caches.
sw-precache
now uses a single cache
As mentioned, the caching logic has been modified to get to the point where we can safely include versioning information about each cached resource in the cache entry's key, meaning that we no longer need to create as many independently versioned caches as we previously did. In practice, this might lead to slightly better performance, without changing any functionality.
New dontCacheBustUrlsMatching
option
By default, sw-precache
adds in a cache-busting URL parameter to request URLs when populating its cache, to ensure that the response used is "fresh" and not served from the browser's HTTP cache. However, if a developer is already "doing the right thing" by explicitly versioning their static resources and setting appropriate long-lived HTTP caching headers, this cache-busting is not needed. The new dontCacheBustUrlsMatching
option takes a regular expression and will skip cache-busting for any resources that match that expression.
New stripPrefixMulti
option
stripPrefixMulti
gives developers more flexibility over translating the paths to resources in the local filesystem to the corresponding URLs that they'll be served from.
Significant PRs Since Previous Release
- supporting multiple stripPrefix & replacePrefix entries via stripPrefixMulti
- Always run sw-precache's fetch handler before sw-toolbox's
- Move to a single cache for all responses
- cli support for maximumFileSizeToCacheInBytes
- Adds a dontCacheBustUrlsMatching option
Thanks
Thanks to @SignpostMarv, @cdbattags, and @jwagner for their PR contributions!