- From: Tobias Lundin <notifications@github.com>
- Date: Mon, 24 Sep 2018 14:50:44 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/issues/493/424001581@github.com>
@grkblood13 actually I found out (this summer) that you are allowed (at least in Chrome) to add anonymous HTTP-requests to the cache 😄 (⚠️)
The issue remains that you CANT know if the data is a-ok or not however since there is no programmatic access to the response 😢
But for my case, **just a private** podcast player - the issue of risk / stability is fine...
The reason this is a big issue for audio is that there are SO MANY podcast providers out there that do not provide CORS headers or HTTPS (and a proxy would just prove to costly).
I was wondering why you would have this issue though?
>From where are you fetching video (what services)?
Are you streaming (hls, hds, dash, etc) or using progressive download (mp4)?
```js
// example using workbox
workbox.routing.registerRoute(
({url}: {url: URL}) => {
// Return true if the route should match
const isMp3 = /\.(?:mp3)$/.test(url.pathname);
// define some own query param to figure out if this is
// a regular request or if this should be cached...
const offline = /podspace-offline/.test(url.search);
return isMp3 && offline;
},
workbox.strategies.cacheFirst({
cacheName: 'audio',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
}),
new workbox.cacheableResponse.Plugin({
statuses: [0, 200]
}),
],
})
);
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/493#issuecomment-424001581
Received on Monday, 24 September 2018 14:51:07 UTC