I am doing a PWA aplication and it works well (Pass al the audits of Chorme) but when i want to try it in offline mode. a 504 TIMEOUT error appears. The DevsTools(Chorme) shows 'An unknown error occurred when fetching the script, Failed to load resource: net::ERR_INTERNET_DISCONNECTED' and Network slice shows a failed when the app try to get "ngsw.json?ngsw-cache-bust=0.30493506524068925"
This is my package:
{
"name": "avl",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.8",
"@angular/cdk": "^7.3.4",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "~7.2.0",
"@angular/http": "^7.2.8",
"@angular/material": "^7.3.4",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/pwa": "^0.13.8",
"@angular/router": "~7.2.0",
"@angular/service-worker": "^7.2.13",
"@mapbox/leaflet-pip": "^1.1.0",
"@types/fontfaceobserver": "^0.0.6",
"@types/leaflet": "^1.4.3",
"@types/pixi.js": "4.7.2",
"cerialize": "^0.1.18",
"core-js": "^2.5.4",
"fontfaceobserver": "^2.1.0",
"leaflet-pixi-overlay": "^1.6.0",
"moment": "^2.24.0",
"net": "^1.0.2",
"pixi.js": "4.7.2",
"rxjs": "~6.3.3",
"rxjs-compat": "6.3.3",
"tslib": "^1.9.0",
"wellknown": "^0.5.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.7",
"@angular/cli": "~7.3.3",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "^7.2.8",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
this is my ngsw-config.json
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js",
"/*.json"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani|json)"
]
}
}
]
}
I expect to see the html of the app with his css
The web manifest looks correct to me.
Service workers do not work with ng serve. So you have to do a prod build (ng build --prod) ans serve the compiled code locally with a web server.
In order to verify if your service worker has been correctly installed and it is running:
If the service worker is running, it will be displayed there.
I wrote a step by step guide for creating an Angular PWA (there is also a final DEMO on Github), maybe you can follow it along and see if anything is missing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With