What causes a Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode error?

后端 未结 2 1884
谎友^
谎友^ 2020-11-29 02:15

After upgrading to Chrome 64, I realized that this error appears when I load my page on a new tab.

I can\'t identify where it is on the service worker. Here

相关标签:
2条回答
  • 2020-11-29 02:54

    perhaps the cache name is not unique from other applications, seems to fix the issue for me.

    0 讨论(0)
  • 2020-11-29 03:09

    I believe this is a Chromium bug that has been reported here. Hopefully it will be fixed soon or some more information about the issue will be published.

    Paul Irish implemented a temporary work around, which is as follows:

    if (e.request.cache === 'only-if-cached' && e.request.mode !== 'same-origin') {
      return;
    }
    

    I ran it inside the callback for the service worker install and fetch listeners and it prevented the error.

    You can see the full commit of Paul's code here.

    0 讨论(0)
提交回复
热议问题