mirror of
https://github.com/Brandon-Rozek/website-theme.git
synced 2025-06-20 18:05:30 +00:00
Compare commits
No commits in common. "55a8368001d86661596f3deda3a7dc291ae864d6" and "df0ec44936cb06d4ec0282e3cd057321ad655b2a" have entirely different histories.
55a8368001
...
df0ec44936
2 changed files with 51 additions and 55 deletions
|
@ -66,7 +66,4 @@
|
||||||
{{- partial "external/twitter_cards.html" . -}}
|
{{- partial "external/twitter_cards.html" . -}}
|
||||||
|
|
||||||
{{ partial "citation.html" . }}
|
{{ partial "citation.html" . }}
|
||||||
|
|
||||||
{{- $script := resources.Get "js/script.js" -}}
|
|
||||||
<script src="{{ $script.Permalink }}" async></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -26,7 +26,7 @@ self.addEventListener('message', event => {
|
||||||
if (event.data.command == 'trimCache') {
|
if (event.data.command == 'trimCache') {
|
||||||
trimCache(version + cacheName, maxItems);
|
trimCache(version + cacheName, maxItems);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// If the version changes, invalidate the cache
|
// If the version changes, invalidate the cache
|
||||||
|
@ -70,14 +70,12 @@ self.addEventListener('fetch', function (event) {
|
||||||
fetch(request).then(function (response) {
|
fetch(request).then(function (response) {
|
||||||
// If successful, create a copy of the response
|
// If successful, create a copy of the response
|
||||||
// and save it to the cache
|
// and save it to the cache
|
||||||
// Note: Ignore badges
|
|
||||||
if (request.url.includes("/badges")) {
|
|
||||||
let cacheCopy = response.clone();
|
let cacheCopy = response.clone();
|
||||||
event.waitUntil(caches.open(version + cacheName).then(function (cache) {
|
event.waitUntil(caches.open(version + cacheName).then(function (cache) {
|
||||||
return cache.put(request, cacheCopy);
|
return cache.put(request, cacheCopy);
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
// Otherwise, check the cache.
|
// Otherwise, check the cache.
|
||||||
return caches.match(request).then(function (response) {
|
return caches.match(request).then(function (response) {
|
||||||
|
@ -86,6 +84,7 @@ self.addEventListener('fetch', function (event) {
|
||||||
return response || caches.match(offlinePage);
|
return response || caches.match(offlinePage);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue