mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Remove service-worker fetch handler entirely when cache disabled (#25591)
Followup to c4559ae575
This commit is contained in:
parent
490041a435
commit
225db41bfc
@ -12,34 +12,7 @@
|
|||||||
workbox_base = "#{base}/assets/#{EmberCli.workbox_dir_name}"
|
workbox_base = "#{base}/assets/#{EmberCli.workbox_dir_name}"
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<% if GlobalSetting.disable_service_worker_cache %>
|
<% if !GlobalSetting.disable_service_worker_cache %>
|
||||||
|
|
||||||
self.addEventListener("activate", (event) => {
|
|
||||||
event.waitUntil(
|
|
||||||
(async () => {
|
|
||||||
if ("navigationPreload" in self.registration) {
|
|
||||||
await self.registration.navigationPreload.enable();
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Tell the active service worker to take control of the page immediately.
|
|
||||||
self.clients.claim();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.addEventListener('fetch', event => {
|
|
||||||
if (event.request.mode === 'navigate') {
|
|
||||||
event.respondWith(
|
|
||||||
fetch(event.request.url).catch(error => {
|
|
||||||
return new Response("<center><h1>You are currently offline</h1><p>Try <a href='#' onclick='window.location.reload()'>refreshing</a></p></center>", {
|
|
||||||
headers: {'Content-Type': 'text/html'}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
<% else %>
|
|
||||||
|
|
||||||
importScripts("<%= "#{workbox_base}/workbox-sw.js" %>");
|
importScripts("<%= "#{workbox_base}/workbox-sw.js" %>");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user