Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!