Open rrroulio opened 4 years ago
I had this issue as well.
To add clarity, the above post is suggesting using that code snippet in serviceworker.js
. For me that was located public/servicewoker.js
just as the docs described in The Service Worker section on how one would customize the service worker's functionality.
Ultimately the above code didn't work for me.
I did end up finding a solution that worked for me by customizing my service worker. I decided to not serve my .mp4 urls from cache. Here's my code snippet:
// Serve from Cache
self.addEventListener("fetch", event => {
if (!event.request.url.endsWith('.mp4')) {
event.respondWith(
caches.match(event.request)
.then(response => {
return response || fetch(event.request);
})
.catch(() => {
return caches.match('offline');
})
)
}
});
There may be a better/more elegant solution and I'm open to hearing them! But for now my videos are playing in Safari :D
.mp4 videos are no longer played in Safari Mac Os and iOS after installing the PWA. After research, I found a solution. I'm not a pro in SW, I can't have a crooked look at this JS but it works fine. The origin is : https://stackoverflow.com/questions/52087208/pwa-cached-video-will-not-play-in-mobile-safari-11-4
Here is the adapted code for laravel-pwa (CURRENT_CACHES change to staticCacheName ) Only fetch part is changed in the original script. ///////////////////////////////
self.addEventListener('fetch', function(event) {
});