In reply to Leonardo Losoviz.

Leo,

I read your article but I’ve not looked at your code but I doubt a generic solution can provide flexibility required, things like notifications, other caching strategies, and postmessage support to name a few.

It certainly can’t without having a dynamic service worker which wil double your server load, not ideal and not necessary.better to make the service worker as static as possible

To that end

Stay away from spas they are the devils spawn (largely another discussion though)

Apart from an offline page there is no real need to pre cache anything else as your first page load will probably pull down all required assets, so as long as those assets go not the right cache/caching strategy you are mostly there.

Tell the service worker about anything else it needs to cache via postmessage