mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
cache legacy js on request
This commit is contained in:
parent
3354d601d1
commit
a94b099819
@ -220,10 +220,10 @@ async function buildJsLegacy(mainFile, extraFiles = []) {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SERVICEWORKER_NONCACHED_ASSETS = [
|
const NON_PRECACHED_JS = [
|
||||||
"hydrogen-legacy.js",
|
"hydrogen-legacy.js",
|
||||||
"olm_legacy.js",
|
"olm_legacy.js",
|
||||||
"sw.js",
|
"worker.js"
|
||||||
];
|
];
|
||||||
|
|
||||||
function isPreCached(asset) {
|
function isPreCached(asset) {
|
||||||
@ -232,7 +232,7 @@ function isPreCached(asset) {
|
|||||||
asset.endsWith(".css") ||
|
asset.endsWith(".css") ||
|
||||||
asset.endsWith(".wasm") ||
|
asset.endsWith(".wasm") ||
|
||||||
// most environments don't need the worker
|
// most environments don't need the worker
|
||||||
asset.endsWith(".js") && asset !== "worker.js";
|
asset.endsWith(".js") && !NON_PRECACHED_JS.includes(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildManifest(assets) {
|
async function buildManifest(assets) {
|
||||||
@ -252,9 +252,7 @@ async function buildServiceWorker(swSource, globalHash, assets) {
|
|||||||
const hashedCachedOnRequestAssets = [];
|
const hashedCachedOnRequestAssets = [];
|
||||||
|
|
||||||
for (const [unresolved, resolved] of assets) {
|
for (const [unresolved, resolved] of assets) {
|
||||||
if (SERVICEWORKER_NONCACHED_ASSETS.includes(unresolved)) {
|
if (unresolved === resolved) {
|
||||||
continue;
|
|
||||||
} else if (unresolved === resolved) {
|
|
||||||
unhashedPreCachedAssets.push(resolved);
|
unhashedPreCachedAssets.push(resolved);
|
||||||
} else if (isPreCached(unresolved)) {
|
} else if (isPreCached(unresolved)) {
|
||||||
hashedPreCachedAssets.push(resolved);
|
hashedPreCachedAssets.push(resolved);
|
||||||
|
Loading…
Reference in New Issue
Block a user