The SW is generated server-side by OPWA_SW_Builder::build() and served at /sw.js with Content-Type: application/javascript.
Strategy descriptions
| Strategy | Behaviour | Best for |
|---|---|---|
network-first | Try network; fall back to cache on error | HTML pages, dynamic content |
cache-first | Serve from cache; update in background | CSS, JS, fonts, images |
stale-while-revalidate | Serve stale cache immediately; fetch update for next time | Frequently-changing assets where slightly stale is OK |
network-only | Never cache; always require network | Checkout, authentication, payments |
cache-only | Only serve from cache; never network | Pre-cached, locked assets |
Cache names
| Cache | Name pattern |
|---|---|
| Pages | opwa-pages-v{sw_version} |
| Static (JS/CSS) | opwa-static-v{sw_version} |
| Images | opwa-images-v{sw_version} |
| Offline | opwa-offline-v{sw_version} |
| Precache | opwa-precache-v{sw_version} |
Cache names are versioned. Bumping sw_version causes the old caches to be deleted on the next SW activate event.
Cache expiry
Each strategy supports maxAge (seconds) and maxEntries. On a cache hit, the SW checks the Date header of the stored response. If older than maxAge, the cached entry is deleted and the request falls through to the network.
