Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only in Chrome (Service Worker): '... a redirected response was used for a request whose redirect mode is not "follow" ' #573

Closed
NathHorrigan opened this issue Aug 1, 2017 · 2 comments

Comments

@NathHorrigan
Copy link

When I refresh (or go offline) in Chrome then I get "This site can't be reached" and the following logged to console: The FetchEvent for "http://localhost:8111/survey/174/deployment/193/answer/offline/attendee/240/" resulted in a network error response: a redirected response was used for a request whose redirect mode is not "follow".. When I refresh in Firefox everything works fine. Could someone explain why this is happening?

Here is my simplified SW.

importScripts("/static/js/libs/idb.js")

var CACHE_NAME = "upshot-cache-version3"
var urlsToCache = [...]

self.addEventListener("install", event => {
  event.waitUntil(
    caches
      .open(CACHE_NAME)
      .then(cache => {
        urlsToCache.map(url => cache.add(url))
      })
  )
})

self.addEventListener("activate", event => {
  clients.claim()
})

self.addEventListener('fetch', event => {
  event.respondWith(
    caches
      .match(event.request)
      .then(response => {
        
        if (response) {
          return response
        }
        
        var fetchRequest = event.request.clone()

        return fetch(fetchRequest).then(response => {
          if (!response || response.status !== 200 || response.type !== 'basic') {
            return response
          }
          var responseToCache = response.clone()
          caches.open(CACHE_NAME).then(cache => cache.put(event.request, responseToCache))
          return response
        })

      })
  )
})
@wanderview
Copy link
Member

This most likely means that cached a request to http://localhost:8111/survey/174/deployment/193/answer/offline/attendee/240 that was redirected to http://localhost:8111/survey/174/deployment/193/answer/offline/attendee/240/. Note the added slash at the end.

Also, FF should behave the same here. Its possible you have slightly different cached data in your different profiles?

@annevk
Copy link
Member

annevk commented Sep 4, 2017

Closing this due to lack of follow-up. It also seems this kind of question is more suitable for Stack Overflow.

@annevk annevk closed this as completed Sep 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants