-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support side-by-side compressed files? #74
Comments
I think that's probably too much magic, unless we can figure out a more general way to express this idea. |
I don't think staticfile should simply assume that those two files have the same content. What's wrong with compressing on-the-fly? |
Nothing is wrong with it, but there has to be increased overhead (not that I've benchmarked it though). If someone uses a compression algorithm like zopfli, which uses more time to compress in exchange for smaller files, then the delay would be even more noticeable. Additionally, compressing the same static file millions of times is inefficient compared to compressing it once. On-the-fly compression is invaluable for operations where the server is generating the content. Ahead-of-time compression is useful for static content. |
From what I understand |
Ah, I was not aware that Hyper / Iron had no desire to participate at this layer of the stack. I can certainly replace or supplant Hyper / Iron with nginx. That does seem to place the staticfile middleware in a strange place though, if serving those types of files is better served by a different piece of software. |
X-Sendfile is particularly popular with webframeworks in slower dynamic In Flask [1] it is implemented the following way: By default, static assets are On Sun, Sep 11, 2016 at 09:12:19AM -0700, Jake Goulding wrote:
|
This is 100% a valid thing to aim for, but I would suggest updating the README with text along these lines to help people understand from the start that this project has an explicit non-goal of replacing solutions such as Nginx etc. when it comes to performance.
From my end of the stick, that's part of the appeal of Rust — reimplementing things. Specifically, I would have wanted Iron (perhaps powered by staticfile) to be able to replace Nginx for this specific usecase (and more and more, eventually). Again, if that's not what the maintainers want, that's absolutely fine, but stating it upfront should help fend off future feature requests. Philosophically, it does get tricky when this is extended to other aspects, such as SSL termination. SSL can be provided by Nginx as a frontend before Iron, yet Iron appears to support it (I haven't used it myself). |
This is my personal perspective, not sure if it's in line with Iron's.
Perhaps I'm routine-blinded, but high-level web application frameworks in general are not designed for the purpose of implementing a web server. That isn't to say that a simple nginx-clone couldn't be implemented in Iron though. Flask's builtin server doesn't scale at all, is vulnerable to a wide range of DoS attacks (single-threaded server). For production, other server implementations are used. However, it does have SSL support (primarily for testing things such as HTTPS redirect behavior), and despite all the listed shortcomings, it is sometimes used for low-traffic intranet sites just because it's already there. Stable Hyper is also just a synchronous threaded server and unlikely to be any better. But development Hyper is different in ways I don't fully understand, so maybe the situation will be completely different and maybe sometime Iron can be used for large-scale websites without nginx. |
And perhaps I might be blinded the other way 😉 Perhaps the "right" solution is to implement something like this atop Hyper (or whatever Tokio grows into) and continue to put it before something more application-focused.
Ditto for Rails. You generally switch to an alternate and put Nginx in front, as you mentioned. However, that doesn't necessarily strike me as The Way Things Must Be. Having never implemented a production-quality web application framework or web server, my opinion doesn't carry much weight, but I'd love it if Rust could basically consolidate those two layers of the modern stack. |
In another project I resolved this by caching the compressed version. Most clients will support gzip so falling back to reloading the file for clients who will only accept plaintext seems reasonable (In the project I've linked I opted to ignore checking the Accept-Encoding header, a shortcut decision that isn't recommended for a general purpose library obviously). This has the bonus of reducing the size of the cache |
If I have a directory with the following contents:
It would be nice to serve the gzipped version when the client asks for
foo.css
. Does this seem like something that is in-scope for this library?The text was updated successfully, but these errors were encountered: