983 B
983 B
1. Setup
- 1.1 Add
sw.jsto site root output (place insite/public/sw.js) - 1.2 Add service worker registration to the base layout (register only in production)
2. Pre-cache Site Shell
- 2.1 Implement versioned cache names and an explicit cache version constant
- 2.2 Implement
installhandler to pre-cache critical shell assets - 2.3 Implement
activatehandler to delete old version caches
3. Runtime Caching
- 3.1 Implement network-first strategy for navigation/document requests with cache fallback
- 3.2 Implement cache-first strategy for images/media with network fallback
- 3.3 Add a bounded eviction policy for media cache size
4. Verification
- 4.1 Verify service worker registers in production build and does not register in dev
- 4.2 Verify repeat navigation and asset loads hit cache (Chrome DevTools Application tab)
- 4.3 Verify a new deploy triggers cache version update and old caches are removed