# Deploying PWAs — Progressive Web Apps: Offline, Installable Web Apps

Source: https://www.skillbyai.com/en/pwa/pwa-deployment

> Deploy your PWA to production with proper caching headers and version management.

## Deployment considerations

Deploy on HTTPS always. Set cache headers: no-cache for HTML, long cache for versioned assets. Use service worker versioning and update checks. Configure CDN for fast delivery.

## Cache header configuration (Nginx)

Proper cache headers for different file types in production.

```nginx
# Cache static assets for 1 year
location ~* \.(js|css|png|jpg|svg)$ {
  expires 365d;
  add_header Cache-Control "public, immutable";
}

# Never cache HTML
location ~* \.html$ {
  expires -1;
  add_header Cache-Control "public, no-cache";
}

# Service worker - short cache
location = /sw.js {
  expires 1d;
  add_header Cache-Control "public, max-age=86400";
}

# Manifest - short cache
location = /manifest.json {
  expires 1h;
  add_header Cache-Control "public, max-age=3600";
}
```

Output:

```
Proper cache headers configured for PWA asset types.
```

## A common trap

Serve `sw.js` with `Cache-Control: no-cache` so updates are found quickly, and keep `manifest.json` on a short cache lifetime.
