getify / cloud-sweeper

A casual game built for the web.
94 stars 17 forks source link

investigate: offline strategies #19

Open getify opened 8 years ago

getify commented 8 years ago

appcache is widespread but dying. serviceworker is on the rise.

should we use both? neither? etc?

joekarl commented 8 years ago

I assume you're just looking at having assets + code cached yes?

getify commented 8 years ago

atm, that's what i'm thinking.

but tbh, there might very well be other kinds of offline-ability that would be interesting to discuss. for example, if the game eventually supports high-score boards or other kinds of tracking of your activity in a centralized account, and you're playing offline, maybe something like service-worker (or local-storage or whatever) could be keeping track of your activity and then sync it up when you go back online.

i'd like to have a broad discussion about strategies and options, since I don't really know what is even possible, entirely.

sintaxi commented 8 years ago

If you ware looking for something low risk and easy you may want to look at the auto.appcache feature we provide with surge.sh. Surge.sh automatically generates an auto.appcache file. All you have to do is link to it in your html tag like so <html manifest="/auto.appcache">

Works in pretty much every browser but like you say, it appears appcache is being EOLed.

Here is a blog post on the topic...

https://davidwalsh.name/dont-wait-serviceworker-adding-offline-support-oneline

justmarkup commented 8 years ago

I would go with service worker only. Appcache is it not worth the trouble in my opinion. Yes, this way it won't work offline in Safari and Edge at the moment but I am sure they will add support sooner or later and I think the more sites/apps use service worker the faster they will implement it :-)

I made a service worker for the game. Code Demo

And as you mentioned high-score boards, there you could use Background Sync

Happy to make a pull request for this.

sintaxi commented 8 years ago

Hard to argue with @justmarkup on this, unless iOS support is a requirement.