PWA Features
- Offline Support - Core functionality available without internet
- Installable - Add to home screen on mobile and desktop
- Fast Loading - Service worker caches assets and data
- Background Sync - Queue updates when offline
- Push Notifications - Real-time alerts (optional)
Configuration
Vite PWA Plugin
World Monitor usesvite-plugin-pwa with Workbox:
vite.config.ts
Web App Manifest
Manifest Fields
The web app manifest defines how World Monitor appears when installed:manifest.webmanifest
Display Modes
- standalone - Full-screen without browser UI (recommended)
- fullscreen - Full-screen with no browser or OS UI
- minimal-ui - Minimal browser UI (back/forward buttons)
- browser - Normal browser tab
standalone for an app-like experience.
Maskable Icons
Maskable icons adapt to different device shapes (rounded corners, circles):Variant-Specific Manifests
Each variant has custom metadata:vite.config.ts
Service Worker
Workbox Configuration
World Monitor uses Workbox for advanced caching strategies:vite.config.ts
Caching Strategies
World Monitor uses different strategies for different resource types:HTML Navigation - Network First
vite.config.ts
API Routes - Network Only
vite.config.ts
Map Tiles - Cache First
vite.config.ts
Fonts - Cache First
vite.config.ts
Images - Stale While Revalidate
vite.config.ts
Service Worker Registration
World Monitor registers the service worker automatically:Service Worker Updates
WithskipWaiting: true and autoUpdate, new versions activate immediately:
Offline Support
Offline Page
World Monitor serves a custom offline page when no cache is available:public/offline.html
Offline Detection
Detect network status in your app:Background Sync
Queue actions when offline, sync when online:Installation
Install Prompt
World Monitor can prompt users to install:Installation Criteria
Browsers show the install prompt when:- The app is served over HTTPS
- A valid web app manifest exists
- A service worker is registered
- The user has visited at least once
- The user has engaged with the site
Installation Methods
- Chrome Desktop
- Safari iOS
- Chrome Android
- Edge Desktop
- Click the install icon in the address bar
- Or: Menu → Install World Monitor
Testing
Lighthouse PWA Audit
Run Lighthouse to check PWA compliance:- Performance: 90+
- Accessibility: 95+
- Best Practices: 95+
- SEO: 95+
- PWA: 100
Service Worker Testing
Test service worker in Chrome DevTools:- Open DevTools (F12)
- Go to Application → Service Workers
- Check “Offline” to simulate offline mode
- Verify caching in Application → Cache Storage
Manifest Testing
Validate manifest in DevTools:- Go to Application → Manifest
- Check all fields display correctly
- Verify icons load
- Test install prompt
PWA Builder
Use PWA Builder to validate and generate app packages:Performance Optimization
Precaching Strategy
Precache only essential assets:Cache Size Limits
Set reasonable cache limits:Network Timeouts
Set aggressive timeouts for faster offline fallback:Troubleshooting
Service Worker Not Updating
Solution: Clear cache and unregister old service worker:Install Prompt Not Showing
Checklist:- Served over HTTPS? (localhost works too)
- Valid manifest.webmanifest?
- Service worker registered?
- User visited before?
- App not already installed?
Cache Not Working
Debug:- Open DevTools → Application → Cache Storage
- Verify caches exist
- Check service worker status
- Look for errors in Console
Manifest Not Loading
Check:- Manifest path correct in HTML:
<link rel="manifest" href="/manifest.webmanifest"> - Manifest served with correct MIME type:
Content-Type: application/manifest+json - No CORS errors (same origin)
Browser Support
- Chrome/Edge: Full PWA support
- Safari: PWA support on iOS 11.3+, limited on macOS
- Firefox: Service workers and manifest, no install prompt
- Samsung Internet: Full PWA support