optimizations
This commit is contained in:
30
sw.js
30
sw.js
@ -7,30 +7,30 @@ let localStorageData = {
|
||||
disableCDN: true,
|
||||
};
|
||||
// yandere sim big files, cuphead, ddlc assets, renpy, renpy, buckshot roulette, half life, undertale & deltarune, hollow knight
|
||||
let cacheable_files = ["YandereSim.data", "cuphead/Build/Build.data.unityweb.", "/ddlc/game/", "/ddlcplus/game/", "/co09/game/", "/co09flipside/game/", "/co09reup/game/", "renpy.data", "game.zip", "buckshot-roulette.pck", "halva_en-", "game.unx", "bog.data", "FTFHAPort.data.unityweb", "Content.tar.part"];
|
||||
let cacheable_files = ["YandereSim.data", "cuphead/Build/Build.data.unityweb.", "/ddlc/game/", "/ddlcplus/game/", "/co09/game/", "/co09flipside/game/", "/co09reup/game/", "renpy.data", "game.zip", "buckshot-roulette.pck", "halva_en-", "game.unx", "bog.data", "FTFHAPort.data.unityweb", "Content.tar.part", "thats-not-my-neighbor.pck", ".unityweb", "index.data.path"];
|
||||
|
||||
self.addEventListener("message", e => {
|
||||
if(e.data && e.data.type == "localStorage") {
|
||||
if (e.data && e.data.type == "localStorage") {
|
||||
localStorageData = e.data;
|
||||
}
|
||||
});
|
||||
|
||||
if(workbox) {
|
||||
self.skipWaiting();
|
||||
workbox.core.clientsClaim();
|
||||
if (workbox) {
|
||||
self.skipWaiting();
|
||||
workbox.core.clientsClaim();
|
||||
|
||||
workbox.routing.registerRoute(
|
||||
({url}) => {
|
||||
if(localStorageData.disableCDN) return false;
|
||||
if(localStorageData.cdns.length == 0) return false;
|
||||
if(url.origin != location.origin) return false;
|
||||
if(!url.pathname.includes("/resources/")) return false;
|
||||
({ url }) => {
|
||||
if (localStorageData.disableCDN) return false;
|
||||
if (localStorageData.cdns.length == 0) return false;
|
||||
if (url.origin != location.origin) return false;
|
||||
if (!url.pathname.includes("/resources/")) return false;
|
||||
for (const file of cacheable_files) {
|
||||
if(url.pathname.includes(file)) return true;
|
||||
if (url.pathname.includes(file)) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
async ({url}) => {
|
||||
async ({ url }) => {
|
||||
let cdn = localStorageData.cdns[0];
|
||||
console.warn(url.href);
|
||||
return Response.redirect(cdn + url.pathname, 302);
|
||||
@ -50,12 +50,12 @@ if(workbox) {
|
||||
})
|
||||
);
|
||||
workbox.routing.registerRoute(
|
||||
/.*resources\/(semag|sppa).*/,
|
||||
/.*resources\/(semag|sppa).*/,
|
||||
new workbox.strategies.CacheFirst({
|
||||
cacheName: 'resources-cache',
|
||||
plugins: [
|
||||
new workbox.expiration.ExpirationPlugin({
|
||||
maxEntries: 500,
|
||||
maxEntries: 700,
|
||||
maxAgeSeconds: 365 * 24 * 60 * 60,
|
||||
}),
|
||||
],
|
||||
@ -63,7 +63,7 @@ if(workbox) {
|
||||
);
|
||||
|
||||
workbox.routing.registerRoute(
|
||||
/.*resources\/(games|apps)\.json$/,
|
||||
/.*resources\/(games|apps)\.json$/,
|
||||
new workbox.strategies.StaleWhileRevalidate({
|
||||
cacheName: 'json-cache',
|
||||
plugins: [
|
||||
|
||||
Reference in New Issue
Block a user