ilan-schemoul / meteor-service-worker

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

Meteor-service-worker vs appcache #12

Closed centinel3 closed 6 years ago

centinel3 commented 7 years ago

Hi NitroBay,

Great looking plugin and am interested in trying it out. My question is, what are the main differences between your service worker plugin and the meteor appcache (https://docs.meteor.com/packages/appcache.html). They seem to solve the same problem of caching assets in the browser. I'm developing an offline first web app and am not sure what the pros/cons are of the 2 possible solutions.

Any feedback is appreciated. Thanks and will talk with you later.

sferoze commented 6 years ago

@centinel3

"Before service worker, there was one other API that gave users an offline experience on the web called AppCache. There are a number of issues with the AppCache API that service workers were designed to avoid."

this link may help explain - https://developers.google.com/web/fundamentals/getting-started/primers/service-workers

ilan-schemoul commented 6 years ago

@centinel3 Very sorry for the late answer but it could still be useful to some to thus I answer now. @sferoze has summed it up pretty well. Appcache was a promising solution but a lot of reasons made it a solution not liked by devs. The core problems was appcache is a declarative* high-level API (so you couldn't make a lot of things as high level = easy to use but less options. I.E : HTML with its english-like tags is a high-level markup language) which brought all cons explained in the article I've linked. Whereas Service Worker is a very low level imperative API so you can do an infinite number of things literally. Appcache has been deprecated anyway and should definitively not be used anymore by anyone. Applied to the Meteor use case for now both are acting pretty much the same but as appcache has been deprecated you should use Service Worker. Moreover if you can understand how SW are working you can do whatever you want and store or not store whatever you want. Modify my code as much as you want. In the future I shall offer a (possibly rich) API and support plugins etc. I've still have to wait for Meteor to let package creators register the service worker automatically. They're waiting for Apple to implement the Service Worker (Apple recently have started the development of this feature). IMO they're making an incredibly terrible move by pushing devs to use appcache instead of Service Workers

“imperative programming is like how you do something, and declarative programming is more like what you do, or something.”

ilan-schemoul commented 6 years ago

As for the last bit of your message I'd be pleased to talk with you for sure even though I now I've answered way too late.