Skip to content

Commit

Permalink
fix(app-shell): match with cache name
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Esquire authored Jun 15, 2020
1 parent 93d0e54 commit 4e2fee0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/middleware/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* permissions and limitations under the License.
*/

import { match, normalizeRequest, put, createCacheName } from '../cache';
import { match, normalizeRequest, put } from '../cache';
import { isServiceWorker, isOffline } from '../utility/runtime';

import { isNavigateRequest, isResponseSuccessful, noop } from './utility';
Expand All @@ -26,7 +26,11 @@ export default function createAppShell({ route = '/index.html', cacheName = 'off
return function appShell(event) {
if (isOffline()) {
if (isNavigateRequest(event.request)) {
event.respondWith(match(request));
event.respondWith(
match(request.clone(), {
cacheName,
}),
);
return true;
}
} else if (event.request.url === request.url) {
Expand All @@ -35,7 +39,7 @@ export default function createAppShell({ route = '/index.html', cacheName = 'off
if (isResponseSuccessful(response)) {
event.waitUntil(
put(request.clone(), response.clone(), {
cacheName: createCacheName(cacheName),
cacheName,
}),
);
}
Expand Down

0 comments on commit 4e2fee0

Please sign in to comment.