fix(pwa): prevent immutable caching of /sw.js and bust SW registration to v5

This commit is contained in:
Amirul Islam Redwan71
2026-12-06 07:19:47 +06:00
parent 9a9021b9c8
commit 7db3f0e72d
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -445,7 +445,7 @@
<script> <script>
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
window.addEventListener('load', function() { window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js', { scope: '/' }) navigator.serviceWorker.register('/sw.js?v=5', { scope: '/' })
.then(function(reg) { .then(function(reg) {
console.log('[Aura PWA] Service Worker registered with scope:', reg.scope); console.log('[Aura PWA] Service Worker registered with scope:', reg.scope);
}) })
+6
View File
@@ -37,6 +37,12 @@ server {
try_files /bimi-logo.svg =404; try_files /bimi-logo.svg =404;
} }
# Service Worker must never be cached as immutable
location = /sw.js {
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
try_files /sw.js =404;
}
# Cache other static assets # Cache other static assets
location ~* \.(css|js|woff2?|ttf|svg|png|jpg|jpeg|ico|gif|webp)$ { location ~* \.(css|js|woff2?|ttf|svg|png|jpg|jpeg|ico|gif|webp)$ {
expires 7d; expires 7d;