node-static
node-static copied to clipboard
Files stored in cache even if cache is disabled
There's a piece of code:
this.stream(pathname, files, new(buffer.Buffer)(stat.size), res, function (e, buffer) {
if (e) { return finish(500, {}) }
exports.store[key] = {
stat: stat,
buffer: buffer,
timestamp: Date.now()
};
finish(status, headers);
});
It should have an if(that.cache) in there to check if the cache is enabled, otherwise the data stored in the cache will never be retrieved and it's just wasting memory. If someone had a lot of static files they would not be happy about all that wasted memory!
Of course as someone pointed out in another ticket, there's a case to be made for eliminating the in-memory cache altogether as reading static files as the OS generally does this caching for you. Caches are more useful for dynamically generated data. Eliminating the in-memory cache would also fix this issue.