Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
Launching webgl in a pwa (offline)

I am working on a PWA (with very basic vanilla JS) and i try to make a unity webGL launch in it even when the user is offline. I have put all of my files on cache but it still does not work. I'm a begginer in this so i'll be very thankfull for any help on this. Here is the content of my service-worker file :

const cacheName = "static"
const appFiles = [
    "./",
    "xmlhttprequest-length-computable.min.js?v=1.5.1.22060315",
    "images/favicon.ico",
    "images/icon.png",
    "style.css",
    "responsiveMinimalTemplateStyles.css",
    "responsiveMinimalTemplateLoader.js",
    "manifest.json",
    "Build/WebGL.loader.js",
    "Build/WebGL.framework.js",
    "Build/WebGL.data",
    "Build/WebGL.wasm"
]
self.addEventListener("install", e => {
    console.log('Install')
    e.waitUntil(
        caches.open(cacheName).then(cache => {
            return cache.addAll(appFiles)
        })
    )
})

self.addEventListener("fetch", e => {
    e.respondWith(
        caches.match(e.request).then(response => {
            return response || fetch(e.request)
        })
    )
}) 

Any ideas ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ok i'm new to this so i'll be answering myself here, if it can help anybody another time. Finally found my answer here (and of course had to adapt it to my own code) : Progressive web app Uncaught (in promise) TypeError: Failed to fetch

Had to complete my self.addEventListener("fetch", request :

self.addEventListener("fetch", e => {
 e.respondWith(
     caches.match(e.request).then(response => {
         if(response){
             console.log('[Service Worker] Récupération de la ressource: '+e.request.url);
             return response
         } else {
             return fetch(e.request).then((response) => {
                 return caches.open(cacheName).then((cache) => {
                     console.log('[Service Worker] Mise en cache de la nouvelle ressource: '+e.request.url)
                     cache.put(e.request, response.clone())
                     return response
                 })
             })
         }
     })
 )
})      
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda