[slightlyoff/ServiceWorker] Declarative `fetch` event (#949)

I'm thinking about this, possible optimization (inspired by Chrome Extensions [1]):

```js
self.addEventListener('fetch', (e) => {
  // ...
}, {
  url: [
    { pathPrefix: '/assets/' }
  ]
})
```

Taking in account that you already want potentially optimize for HTTP 2 (https://github.com/slightlyoff/ServiceWorker/issues/756), this could be also possible optimization. In case of such declarative filters, SW instance will be spawned only if route matches definition. In the code above, SW will be spawned only for router with path which starts with `/assets/` and won't be spawned from routes such as `/api/*` which potentially are requested more often than `/assets/` routes.


[1] [Filtered events](https://developer.chrome.com/extensions/events#filtered)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/949

Received on Wednesday, 10 August 2016 20:32:51 UTC