Skip to content

Commit c78a513

Browse files
committed
[Test] test fetch API redirect-mode
1 parent 7b469bb commit c78a513

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sw.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ self.addEventListener('fetch', event => {
6161
event.respondWith(
6262
caches.open(RUNTIME).then(cache => {
6363
return caches.match(event.request).then(cachedResponse => {
64+
// Under HSTS, unsecure resources response 307 redirect which broke cache.
65+
var fixedUrl = event.request.url.replace('http://', '//')
6466
// cache busting
65-
var fetchPromise = fetch(`${event.request.url}?${Math.random()}`, {cache: "no-store"})
67+
var fetchPromise = fetch(`${event.request.url}?${Math.random()}`, {
68+
cache: "no-store",
69+
redirect: "follow"
70+
})
6671
.then(networkResponse => {
6772
var resUrl = networkResponse.url
6873
cache.put(event.request, networkResponse.clone())

0 commit comments

Comments
 (0)