Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
precaching plugin
see: GoogleChrome/workbox#1663
  • Loading branch information
nukash committed Oct 1, 2020
1 parent 0f64393 commit 36b4a54
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ self.addEventListener("message", (e) => {
workbox.core.clientsClaim(); // Vue CLI 4 and Workbox v4, else
// workbox.clientsClaim(); // Vue CLI 3 and Workbox v3.

const cacheKeyWillBeUsed = ({ request }) => {
const url = workbox.precaching.getCacheKeyForURL(request.url);
return new Request(url, { headers: request.headers });
};
workbox.routing.registerRoute(
({ url }) => url.pathname.endsWith(".mp3"),
new workbox.strategies.CacheFirst({
// cacheName: "mp3-caching",
cacheName: workbox.core.cacheName.precaching,
plugins: [
new workbox.cacheableResponse.Plugin({
statuses: [200],
}),
// new workbox.cacheableResponse.Plugin({
// statuses: [200],
// }),
{ cacheKeyWillBeUsed },
new workbox.rangeRequests.Plugin(),
],
matchOptions: {
Expand Down

0 comments on commit 36b4a54

Please sign in to comment.