-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
serving memory stored static files? #964
Comments
What is the question? |
Is there an existing plugin? |
No such plugin exists that I know of. My opinion is that static assets are better served by a tool designed for serving them, e.g. nginx. |
This is a very obvious opinion. I also thought of that. But in the end, sometimes you just want to serve a bunch of files. |
This can be a huge footgun, as the content of the files might cause the process to exit with an out of memory error. My guess is that we could at increase the perf of A slightly better approach would be to overhaul |
@mcollina a little more detail about the caching logic that you expect? Draft PR: barelyhuman/send#1 If that's correct then the cache wouldn't work because the reference to the complete buffer would be lost the moment the stream ends. If what's implemented is wrong, then I'd like to understand what the expectation of the cache was. |
The store would need to be passed in to |
I've made changes to it, please confirm the expectation. I also wanted to point of that there's an issue in the tests where the reference stays alive when using a stream. I'm unaware of the reason so I'm still looking into it . |
I felt that multiple times, I wanted to serve a firstful of static files. LIke favicon.ico, a css, a html, and a frontend js file. They make maybe around 1 - 2 mb. But using fastify-static feels wrong. I just want to serve these files over and over. They never change.
fastify-static is reading every time the file from the disk. everytime it generates the etag.
What I could do, is explicitly loading the files via fs.readFileSync and store them as buffer and just send them directly via the handler.
Of course I simplify my case very much. E.g. @fastify/send also handles etags and stuff. And compression is also not implemented. But well... its a poc.
For comparison the example/server.js in fastify-static.
index.html (standard fastify-static)
ondex.html (just buffered)
The text was updated successfully, but these errors were encountered: