GoogleChromeLabs / sw-precache

[Deprecated] A node module to generate service worker code that will precache specific resources so they work offline.
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
5.23k stars 389 forks source link

service worker CORS opaque response error #372

Closed christopher-johnson closed 5 years ago

christopher-johnson commented 5 years ago

I have implemented service worker on my website https://iiif.cloud.

I am noticing a networking issue with fetch and CORS. Here is a testable example: https://iiif.cloud/view/dc662243-42ca-546c-a022-aa00ed0b2e54

The openseadragon viewer initiates a tile fetch for the navigator thumbnail when a new canvas is loaded (by clicking on a new image in the reference strip for example). The initial tile fetch response is a opaque and fails with an error. AFAICT, the image server responses are not opaque, however.

See https://github.com/ubl-chj/collections-ui/issues/2

christopher-johnson commented 5 years ago

The problem occurs in Chrome always, and only Firefox on Windows. Firefox in Linux does not seem to support runtime caching (?).

Here is the config for reference:

runtimeCaching: [{
        // Match any request for Images
        urlPattern: /.*jpg/, 
        handler: 'staleWhileRevalidate', 
        options: {
          cacheableResponse: {
            statuses: [0, 200]
          }, 
          cacheName: 'images', 
          expiration: {
            maxAgeSeconds: 7 * 24 * 60 * 60,
          },
        },
      }]
christopher-johnson commented 5 years ago

The problem is due to the fact that the image server does not support the OPTIONS method. Closing as invalid.