angularjsservice-workersw-precache

Angular Template Cache with Service Worker Issue


I have a gulp setup that puts all my html in template cache for faster access in angular. I'm trying to add a service worker to my project, using sw-precache, so that it can be used offline. If I'm connected to the network, everything works fine. When I go offline, the requests for html resources (that are in the template cache) fail because it seems it is requesting the path from the network.

Is there something I need to add to my sw-precache config in order to have it defer to angular to handle retrieval of html files?


Solution

  • my original solution was not 100%

    To solve this, use sw-precache and sw-toolbox

    Using a gulp configuration you can setup sw-precache to cache you content and extend this with sw-toolbox to use cached responses based upon routing configuration

    see: https://developers.google.com/web/ilt/pwa/using-sw-precache-and-sw-toolbox