Service worker configuration
The application uses Angular’s Service Worker for comprehensive PWA support:app.module.ts:103-106
The service worker is disabled in development mode and registers 30 seconds after the app becomes stable in production, ensuring optimal performance.
Caching strategy
The service worker configuration defines two asset groups with different caching strategies:- App shell
- Assets
Prefetch strategy
Critical application files are prefetched immediately on installation:ngsw-config.json:4-16
- Downloads all specified resources during service worker installation
- Ensures instant availability even on first offline visit
- Ideal for critical app shell resources
The app shell includes the HTML, CSS, JavaScript bundles, and web manifest - everything needed for the app to start.
Web app manifest
The manifest defines how the app appears when installed:View complete manifest configuration
View complete manifest configuration
manifest.webmanifest
Manifest properties explained
Display mode
standalone: App runs in its own window without browser UI, providing a native app experience
Theme color
#1976d2: Material Design blue, applied to browser UI elements and splash screen
Icons
8 sizes: From 72x72 to 512x512 pixels for different devices and contexts
Purpose
maskable any: Icons work with adaptive icon masks and fallback to any shape
Offline functionality
The service worker enables the app to work offline through intelligent caching:Initial visit
On the first visit, the service worker installs and prefetches the app shell (HTML, CSS, JS).
Offline access
When offline, all previously cached resources are served from the cache, allowing full app functionality.
Installation experience
Users can install the PWA to their device:Desktop installation
- Browser shows an install button in the address bar
- Clicking installs the app to the operating system
- App appears in the application menu/dock
- Opens in standalone window without browser chrome
Mobile installation
- Browser prompts “Add to Home Screen”
- App icon appears on home screen
- Launches fullscreen like a native app
- Splash screen uses theme and background colors
Installation is optional - the app works perfectly in the browser. Installation provides a more integrated experience.
Registration strategy
The service worker uses a stability-based registration:- Service worker registration waits until the app is stable
- If not stable after 30 seconds, registers anyway
- Prevents registration from interfering with initial load
- Optimizes First Contentful Paint (FCP) and Time to Interactive (TTI)
PWA best practices implemented
Fast loading
Fast loading
- App shell architecture with prefetched critical resources
- Lazy loading for non-critical assets
- Optimized bundle sizes with code splitting
Offline functionality
Offline functionality
- Service worker caches all visited pages
- Static assets cached on first use
- App shell always available offline
App-like experience
App-like experience
- Standalone display mode
- Custom splash screen
- Theme color integration
- No browser UI when installed
Progressive enhancement
Progressive enhancement
- Works without service worker in older browsers
- Graceful degradation for unsupported features
- Service worker optional, not required
Testing PWA features
To test PWA functionality:Chrome DevTools Application tab shows service worker status, cached resources, and manifest information for debugging.
Next steps
Routing system
Understand the application routing configuration
Service architecture
Learn about the service layer pattern
Installation
Set up your development environment
Architecture overview
Review the overall architecture