ilan-schemoul / meteor-service-worker

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

POST exception #21

Closed raphaelarias closed 5 years ago

raphaelarias commented 5 years ago

Thanks for the initiative.

We keep getting this error:

Uncaught (in promise) TypeError: Request method 'POST' is unsupported at sw.js:58

image

The line with error is: caches.open(version).then(cache => cache.put(event.request, clonedResponse));

Would you know why is it throwing an error on a dynamic import?

For now I've put:

if (event.request.method !== 'POST') { caches.open(version).then(cache => cache.put(event.request, clonedResponse)); }

ilan-schemoul commented 5 years ago

Because Service Workers cannot cache POST, your solution is valid. I'll update the SW later. When I created this SW dynamic-import was not a thing therefore I didn't see that use case. Thanks.

guidouil commented 5 years ago

Now I'm getting it to. Can you please fix it ? Pretty please 🙏

raphaelarias commented 5 years ago

PS: We had to stop using the SW for now, because even with my workaround, it was breaking some of our uploads to S3. We didn't have time to reproduce, and I don't know exactly when it happened, but by removing the SW it fixed.