fix: do not cache sw requests
All checks were successful
Docs / build (push) Successful in 2m4s

This commit is contained in:
alina 🌸 2025-01-19 22:59:18 +03:00
parent c3bd3a8f6a
commit 4463626232
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI

View file

@ -23,15 +23,6 @@ function onFetch(event: FetchEvent) {
const req = event.request const req = event.request
const url = new URL(req.url) const url = new URL(req.url)
if (
import.meta.env.PROD
&& !IS_SAFARI
&& event.request.url.indexOf(`${location.origin}/`) === 0
&& event.request.url.match(/\.(js|css|jpe?g|json|wasm|png|mp3|svg|tgs|ico|woff2?|ttf|webmanifest?)(?:\?.*)?$/)
) {
return event.respondWith(requestCache(event))
}
if (url.pathname.startsWith('/sw/')) { if (url.pathname.startsWith('/sw/')) {
event.respondWith( event.respondWith(
handleSwRequest(req, url) handleSwRequest(req, url)
@ -41,6 +32,15 @@ function onFetch(event: FetchEvent) {
}), }),
) )
} }
if (
import.meta.env.PROD
&& !IS_SAFARI
&& event.request.url.indexOf(`${location.origin}/`) === 0
&& event.request.url.match(/\.(js|css|jpe?g|json|wasm|png|mp3|svg|tgs|ico|woff2?|ttf|webmanifest?)(?:\?.*)?$/)
) {
return event.respondWith(requestCache(event))
}
} }
function register() { function register() {