According to workbox doc, cross domain request should be configured to ensure that regular expression matches the beginning of the URL. However, it doesn't work.
The service worker code is like below.
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js');
workbox.routing.registerRoute(
/.*\.(png|jpg|jpeg|svg|gif)/,
workbox.strategies.cacheFirst()
);
workbox.routing.registerRoute(
new RegExp('^https://a248.e.akamai.net/.*'),
workbox.strategies.cacheFirst()
);
In the page, responses from same origin resources are cached, but responses from https://a248.e.akami.net
is not.
Anything wrong with my config? or is this a workbox 3.0.0 bug?
networkFirst
andstaleWhileRevalidate
strategies (documentation version 6.0.2) state that they cache opaque (that's how the documentation calls responses which don't support CORS) responses as well, so we can use those too? – Jenette