RTSDA-Website/astro-church-website/public/sw.js
Benjamin Slingo 16caf6c3c4 Add PWA support and fix PO BOX display in address
- Add comprehensive PWA configuration with manifest, service worker, and meta tags
- Replace Android APK download with cross-platform PWA installation
- Fix church address to include PO BOX information from API
- Update contact page and footer to properly display multi-line addresses
- Enable native app-like experience on all platforms without app store requirements
2025-08-26 16:49:47 -04:00

43 lines
888 B
JavaScript

const CACHE_NAME = 'rtsda-church-v1';
const urlsToCache = [
'/',
'/about',
'/contact',
'/sermons',
'/events',
'/live',
'/manifest.json'
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((response) => {
// Return cached version or fetch from network
return response || fetch(event.request);
})
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
return caches.delete(cacheName);
}
})
);
})
);
});