We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf875ad commit 4a7b14eCopy full SHA for 4a7b14e
index.js
@@ -54,6 +54,15 @@ function decodeAssetCacheName(encodedString) {
54
return decodedFileName.split(":");
55
}
56
57
+function touch(path) {
58
+ const time = new Date();
59
+ try {
60
+ fs.utimesSync(path, time, time);
61
+ } catch (err) {
62
+ fs.closeSync(fs.openSync(path, "w"));
63
+ }
64
+}
65
+
66
const middleWare = (module.exports = function(options) {
67
return async function(req, res, next) {
68
options = options || {};
@@ -78,6 +87,9 @@ const middleWare = (module.exports = function(options) {
78
87
if (fs.existsSync(assetCachePath)) {
79
88
const firstFile = fs.readdirSync(assetCachePath)[0];
80
89
90
+ // touch file for LRU eviction
91
+ touch(`${assetCachePath}/${firstFile}`);
92
81
93
const [contentType, contentLength] = middleWare.decodeAssetCacheName(
82
94
firstFile
83
95
);
0 commit comments