I developed an Angular PWA demo application (Angular v9.1.3), implementing performance
and freshness
strategies.
Locally it works perfectly, even offline. But once deployed on Github pages, it is not working anymore as expected:
performance
strategy keeps fetching all Requests from the network, not from the cache- Once offline, the app doesn't work, as nothing seems to be cached
I use angular-cli-ghpages
to deploy to gh-pages with the following command (angular-pwa-boilerplate is the Repo name):
ng deploy --base-href=/angular-pwa-boilerplate/
Once deployed, I adjust the start_url
property of the web-manifest file to "/angular-pwa-boilerplate/" to reflect the subdirectory structure.
Even though the scope path seems being correct and the app is installable, the service worker does not caches the assets nor the Http Responses (while locally all is fine).
I read many articles about it, but all the fixes did not work:
- Use a relative path
./
for the service worker file:
ServiceWorkerModule.register('./ngsw-worker.js', ...)
- Set relative values for scope and start_url in manifest file:
"scope": ".",
"start_url":" "./"
Here the DEMO and Github Repo
It seems also that there is still some ongoing work on this topic.
UPDATE
I noticed that if I leave start_url: "/"
(hence without adjusting it to the base-href), Angular Service Worker and its caching strategies work like a charm also on gh-pages.
However the app is no more installable: