File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,15 @@ function decodeAssetCacheName(encodedString) {
54
54
return decodedFileName . split ( ":" ) ;
55
55
}
56
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
+
57
66
const middleWare = ( module . exports = function ( options ) {
58
67
return async function ( req , res , next ) {
59
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
) ;
You can’t perform that action at this time.
0 commit comments