RTSDA-Website/public/sw.js
Benjamin Slingo 91a1bb7a54 Restructure project and update gitignore
- Flatten directory structure by moving files from astro-church-website/ to root
- Remove church-core subdirectory in favor of inline Rust library
- Update .gitignore to properly exclude build artifacts, generated files, and dependencies
- Add environment variables, IDE files, and coverage reports to gitignore
- Include generated CSS files and native bindings in ignore patterns
2025-08-30 08:59:27 -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);
}
})
);
})
);
});