$ cnpm install sw-cache-options
CacheQueryOptions polyfillnpm install -i sw-cache-options
dist/sw-cache-options.js into your projectimportScripts('sw-cache-options.js')This is a polyfill for CacheQueryOptions of ServiceWorker. At a momemnt, Chrome (and its family) doesn't support it natively, so polyfill required. Chrome is sniffed by user agent, exactly this way:
const isChrome = navigator.userAgent.indexOf('Chrome/') !== -1
ignoreSearch is implemented for all methods which accepts it.ignoreMethod is implemented for all methods which accepts it.ignoreVary is not implemented. Reason is that it requires getting all responses (Cache#matchAll()), which might not be so bad, I do not want to deal with it a moment. Feel free to make a PR for it.Browsers which support CacheQueryOptions nativily: Firefox.
Open https://rawgit.com/NekR/sw-cache-options/master/tests/index.html in target browser and open DevTools console, tests' resulsts are logged into it.
Tests can be run againt any browser with ServiceWorker support, since they check general support of CacheQueryOptions. However, polyfill is applied only in Chrome-family browsers, so for actuall results test there. To test in other browser:
src/index.js and comment the line if (!isChrome) return;gulp buildhttp-server -p 7777 -c-1localhost:7777/tests/index.html and open DevTools console to see resultsMIT
Copyright 2013 - present © cnpmjs.org | Home |