Angular PWA does not work when change to OFFLINE and press Refresh (F5)

Discussão em 'Angular' iniciado por Redplane, Fevereiro 16, 2025.

  1. Redplane

    Redplane Guest

    I'm using angular to make PWA app.

    • Angular: 12

    What is going on is:

    • I go to my app (online mode) -> The web app can display properly
    • Turn on developer console and change connectivity to OFFLINE
    • Press F5 to reload the application

    What happens:

    • The below image is what it displays on the screen when I hit reload:

    [​IMG]

    This is my ngsw-config.json

    {
    "$schema": "../../node_modules/@angular/service-worker/config/schema.json",
    "index": "/index.html",
    "assetGroups": [
    {
    "name": "app",
    "installMode": "prefetch",
    "resources": {
    "files": [
    "/favicon.ico",
    "/index.html",
    "manifest.json",
    "/*.css",
    "/*.js"
    ]
    }
    },
    {
    "name": "assets",
    "installMode": "lazy",
    "updateMode": "prefetch",
    "resources": {
    "files": [
    "/assets/**",
    "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
    ]
    }
    }
    ]
    }


    • manifest.json

    {
    "name": "ng-main",
    "short_name": "ng-main",
    "theme_color": "#1976d2",
    "background_color": "#fafafa",
    "display": "standalone",
    "scope": "./",
    "start_url": "./",
    "icons": [
    {
    "src": "assets/icons/icon-72x72.png",
    "sizes": "72x72",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-96x96.png",
    "sizes": "96x96",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-128x128.png",
    "sizes": "128x128",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-144x144.png",
    "sizes": "144x144",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-152x152.png",
    "sizes": "152x152",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-192x192.png",
    "sizes": "192x192",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-384x384.png",
    "sizes": "384x384",
    "type": "image/png",
    "purpose": "maskable any"
    },
    {
    "src": "assets/icons/icon-512x512.png",
    "sizes": "512x512",
    "type": "image/png",
    "purpose": "maskable any"
    }
    ]
    }

    Continue reading...

Compartilhe esta Página