Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda