ilan-schemoul / meteor-service-worker

An universal service worker for meteor apps
MIT License
137 stars 26 forks source link

cache.put receiving request and not the static files #22

Closed EloyID closed 2 years ago

EloyID commented 4 years ago

I'm not totally sure about this, just came here from your post. Verify it's correct, but I think cache.put should receive the request and not the html files

Custard7 commented 3 years ago

Thanks for this @EloyID!

My service working was throwing an error because of the same line, causing quite a few oddities. I changed: Line 88: caches.open(version).then(cache => cache.put(event.request.url, clonedResponse)); Line 99: caches.open(version).then(cache => cache.put(event.request.url, clonedResponse));

Now it is working very well for my app!

ilan-schemoul commented 2 years ago

Hey, Thank you very much for your interest. Actually the reason I put cache.put(HTMLToCache, clonedResponse) was because Meteor projects are SPA (single web page application) so every single page has the same HTML. It means that it was a waste a space to cache each page differently. Instead if HTML is request I always cache under the same request url ('/') and I serve it if HTML is required.