mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-14 03:23:41 +02:00
Update sw.js
This commit is contained in:
parent
e8dd97a291
commit
9a2e937f1b
1 changed files with 3 additions and 4 deletions
|
@ -50,7 +50,6 @@ function fetchContent(event) {
|
||||||
|
|
||||||
self.addEventListener("fetch", event => {
|
self.addEventListener("fetch", event => {
|
||||||
const url = new URL(event.request.url);
|
const url = new URL(event.request.url);
|
||||||
|
|
||||||
const origin = (url.origin == location.origin) ? true : false; // Is same-origin
|
const origin = (url.origin == location.origin) ? true : false; // Is same-origin
|
||||||
|
|
||||||
// Fetch cross-origin content
|
// Fetch cross-origin content
|
||||||
|
@ -61,8 +60,8 @@ self.addEventListener("fetch", event => {
|
||||||
|
|
||||||
// Get pattern.gif from generator. Fallback to cache on failure
|
// Get pattern.gif from generator. Fallback to cache on failure
|
||||||
if(origin && url.pathname.endsWith("pattern.gif")) {
|
if(origin && url.pathname.endsWith("pattern.gif")) {
|
||||||
const pattern = new Request(`${location.origin}/${root}/assets/img/pattern.php`);
|
const pattern = new Request(`${location.origin}/${root}assets/img/pattern.php`);
|
||||||
event.respondWith(fetch(pattern) || caches.match(event.request).then(response => response));
|
event.respondWith(fetch(pattern) || caches.match(url.pathname).then(response => response));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue