Last active
May 2, 2024 18:55
-
-
Save ahmetilhn/f866ff75e8dfa7ab1f224207413adb4c to your computer and use it in GitHub Desktop.
Service worker fetch listener (by ahmetilhn)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// self = context | window | provider | |
self.addEventListener('fetch', function(event) { | |
// İstek gitmeden önce yakalanır ve iptal edilir | |
event.respondWith( | |
fetch(event.request).then(response => { | |
// Burada response nesnesini özelleştirebilir veya değiştirebilirsiniz | |
return response; | |
}).catch(error => { | |
// Ağ hatası durumunda önbellekten bir kaynak döndürmek | |
return caches.match('/offline.html'); | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment