mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.51k stars 475 forks source link

Added service worker with cache first strategy #30

Closed ishanjain28 closed 7 years ago

ishanjain28 commented 7 years ago

Hi,

json-to-go doesn't really needs internet access once the website has loaded in browser. And sometimes people don't have internet access but they still want to use json-to-go. As this tool is hosted on Github pages so we can't really set Cache-Control headers but we can use service workers.

So, I added a service worker with Cache First strategy. There are plenty of browsers that support service workers and once this service worker is installed they'll be able to use json-to-go even when they don't have internet access.

I excluded analytics.js from the list of files that should be cached because it'll require internet access.

Regards Ishan Jain

ishanjain28 commented 7 years ago

To see it in action, Open https://ishanjain28.github.io/json-to-go, turn off internet, and reload the page.. :)

mholt commented 7 years ago

This is cool! Thank you.