-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Etag performance by caching fs.stats #36
Comments
I would wait for nodejs/node#46345 I am thinking, are we open into race-condition of read file. If true, would |
Is a filehandle not created on every request then? But you are right. It is kind of racy if the file is changing. Thats why I would suggest this for non changing filesystems. Like when you do wildcard: false in fastify-static. Maybe this has to be done in fastify-static? |
I expect it to be created on every request. Caching
Yes, for me. Caching is better to be done on higher level. |
I'm not sure what's the right level to put caching. I think we might want to do in this module, but that would require a significant amount of API changes. |
Prerequisites
🚀 Feature Proposal
Cache fs.stats result of files to improve performance. For this we could use an lru. If we know that the exposed files and folders are not changed we can store them without issues. But if we know that the files are getting modified it would make sense to use fs.watch and invalidate the lru. But it would be preferable to assume that e.g. fastify-static is running on a system were the files are not changed.
Motivation
I think the performance bottleneck of this library is the fs.stars call. By caching we could improve the performance.
Example
No response
The text was updated successfully, but these errors were encountered: