Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jul 8, 2020
1 parent 788f831 commit 0e0b219
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions packages/docusaurus-plugin-pwa/src/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ function getPossibleURLs(url) {

self.addEventListener('fetch', async (event) => {
if (params.offlineMode) {
const possibleURLs = getPossibleURLs(event.request.url);
const requestURL = event.request.url;
const possibleURLs = getPossibleURLs(requestURL);
for (let i = 0; i < possibleURLs.length; i += 1) {
const cacheKey = controller.getCacheKeyForURL(possibleURLs[i]);
const possibleURL = possibleURLs[i];
const cacheKey = controller.getCacheKeyForURL(possibleURL);
if (cacheKey) {
if (params.debug) {
console.log('[Docusaurus-PWA][SW]: serving cached asset', {
url: event.request.url,
requestURL,
possibleURL,
possibleURLs,
cacheKey,
});
}
event.respondWith(caches.match(cacheKey));
Expand Down
2 changes: 1 addition & 1 deletion website/src/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {StaleWhileRevalidate} from 'workbox-strategies';

export default function swCustom(params) {
if (params.debug) {
console.log('Docusaurus PWA: running swCustom', params);
console.log('[Docusaurus-PWA][SW]: running swCustom code', params);
}

// Cache responses from external resources
Expand Down

0 comments on commit 0e0b219

Please sign in to comment.