GoogleChromeLabs / sw-toolbox

[Deprecated] A collection of service worker tools for offlining runtime requests
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
3.62k stars 331 forks source link

Accept CacheQueryOptions via the `options.cache` config #239

Closed jeffposnick closed 7 years ago

jeffposnick commented 7 years ago

Now that CacheQueryOptions is widely supported, we should let developers pass it in to configure how the underlying cache.match() behaves inside a handler.

We're already doing something similar in sw-helpers.

The interface would look something like:

toolbox.router.get(new RegExp('/path/to/file'), toolbox.networkFirst, {
  cache: {
    name: 'my-cache',
    queryOptions: {
      ignoreSearch: true,
      // Any other supported options...
    }
  }
});

And then options.cache.queryOptions would get passed in as the second parameter to cache.match().

CC: @mohsen1

jeffposnick commented 7 years ago

(I realize that I neglected to add any tests—those are incoming.)