mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Added caching of files.
This commit is contained in:
parent
a63c27df0f
commit
e973382e05
1 changed files with 8 additions and 0 deletions
|
@ -232,7 +232,12 @@ const statFile = async (filename, dirStatLimit) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let contentCache = new Map();
|
||||||
|
|
||||||
const getFileCompressed = async (filename, contentType) => {
|
const getFileCompressed = async (filename, contentType) => {
|
||||||
|
if (contentCache.has(filename)) {
|
||||||
|
return contentCache.get(filename);
|
||||||
|
}
|
||||||
let content = await getFile(filename);
|
let content = await getFile(filename);
|
||||||
if (!content || !settings.minify) {
|
if (!content || !settings.minify) {
|
||||||
return content;
|
return content;
|
||||||
|
@ -254,6 +259,7 @@ const getFileCompressed = async (filename, contentType) => {
|
||||||
console.error('getFile() returned an error in ' +
|
console.error('getFile() returned an error in ' +
|
||||||
`getFileCompressed(${filename}, ${contentType}): ${error}`);
|
`getFileCompressed(${filename}, ${contentType}): ${error}`);
|
||||||
}
|
}
|
||||||
|
contentCache.set(filename, content);
|
||||||
resolve(content);
|
resolve(content);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -273,10 +279,12 @@ const getFileCompressed = async (filename, contentType) => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`CleanCSS.minify() returned an error on ${filename}: ${error}`);
|
console.error(`CleanCSS.minify() returned an error on ${filename}: ${error}`);
|
||||||
}
|
}
|
||||||
|
contentCache.set(filename, content);
|
||||||
resolve(content);
|
resolve(content);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
contentCache.set(filename, content);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue