Skip to content

Slow output for larger files #19

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

Closed
kazzkiq opened this issue Jan 30, 2019 · 2 comments
Closed

Slow output for larger files #19

kazzkiq opened this issue Jan 30, 2019 · 2 comments

Comments

@kazzkiq
Copy link

kazzkiq commented Jan 30, 2019

I tried to use sirv to deliver a moderately large JS file (~400kb) in dev environment, and noticed it had trouble handling it fast, even being static.

By opening it directly in browser, it took some seconds to load all its content. By fetching it via AJAX (my usage for this project) it also took the same time.


Edit:

Here is a sample file, but I believe it may happen with any other format.

@lukeed
Copy link
Owner

lukeed commented Jan 30, 2019

Hey, this will be improved in the next major version of sirv – getting 1.0 out the door is near the top of my TODO list. Immediately after, 2.0 will be released with HTTP/2 support. This is when the problem will be fixed.

Unfortunately, in HTTP/1, the only way Node.js can send a file is by reading it & piping the contents to the response. Currently, sirv does this the most efficient way possible thru fs.createReadStream. It can only be improved further if sirv held all your files' contents in memory, but this can quickly cause other problems 😕

@lukeed lukeed closed this as completed in 135db55 Apr 15, 2019
@lukeed
Copy link
Owner

lukeed commented Apr 15, 2019

Completely forgot about Range/partial requests! 🤦‍♂️ All browsers will do this by default for large files (eg, videos, PDFs) so it will seemingly speed up these large assets by sending them down in pieces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants