vite-plugin-pwa icon indicating copy to clipboard operation
vite-plugin-pwa copied to clipboard

After a while my pwa looses all caching and data with the error message "Can't connect to the site"

Open trashhead opened this issue 1 year ago • 3 comments

I have this pwa and when it works it works almost perfectly. I can kill the app, turn off the internet connection and it still works. The app is hosted internally at my client. So I can also turn off the vpn and open the app and it still works. All the pages and all my offline data/local storage is there. But all of a sudden when I open the application after a few days or a week everything is gone. All the cached resources, all my offline data in local storage is gone. Is there a configuration issue or something else?

Here is my vite pwa-configuration:

plugins: [
    react(),
    VitePWA({
      registerType: 'prompt',
      workbox: {
        globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}']
      },
      manifest: {
        "theme_color": "#005370",
        "background_color": "#005370",
        "icons": [
          {
            src: 'icon192_rounded.png',
            sizes: '192x192',
            type: 'image/png'
          },
          {
            "purpose": "maskable",
            "sizes": "512x512",
            "src": "icon512_maskable.png",
            "type": "image/png"
          },
          {
            "purpose": "any",
            "sizes": "512x512",
            "src": "icon512_rounded.png",
            "type": "image/png"
          }
        ],
        "orientation": "portrait",
        "display": "standalone",
        "dir": "ltr",
        "lang": "sv",
        "name": "QuickTag",
        "short_name": "QuickTag",
        "description": "QuickTag app for inspections"
      }
    })
  ],

This is how the app looks like on the phone when it fails: image

And this is how the app looks like in chrome remote debugger: image

Can someone explain why it behaves like this? It is a showstopper for the client since all data they are creating offline might disappear.

trashhead avatar Jan 02 '24 08:01 trashhead

If PWA is installed, check you've disabled clearing app data from Android settings

userquin avatar Jan 02 '24 11:01 userquin

If PWA is installed, check you've disabled clearing app data from Android settings

I am using power saving mode always. Maybe that is one clue to the problem. One thing I noticed now when I connected my vpn again and opened my app is that in some way my local storage was back. As we can see in the image above it is empty, but when I opened the app all my offline items were back that I had created when I was offline.

Maybe some sort of hibernation of the app due to battery saving? I will turn off battery saving for a couple of weeks and see if there is a difference. Thank you for the tip.

trashhead avatar Jan 02 '24 13:01 trashhead

Any solution? :)

ksielyov avatar Jan 23 '24 18:01 ksielyov