-
Notifications
You must be signed in to change notification settings - Fork 228
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 gzip static serving #134
Conversation
Thank you. Though this is appreciated, it is a feature that is not desired in this package (see previous issues regarding this). You are always welcome to publish this to npm as a fork if you desire, as the code is MIT licensed. |
Hi, I think expressjs/compression is good for dynamic api serving but not good for static gzip file serving because it make compression on every response, which means a lot of cpu usage. In fact, Pre-compression file serving is a very basic feature for a static file server, you may have a look at ngx_http_gzip_static_module and found it simple but useful. |
Unfortunately all static file serving is not good to be done by Node.js, as Node.js does all file I/O on a thread pool, which has only limited threads and CPU usage. You should always use a proper file server like NGINX, Apache, or a CDN with Node.js as the origin server if at all possible. |
If all static file serving should be done by NGINX / Apache, then why should expressjs/serve-static be there? |
You've already written the code and there is nothing that would keep you from publishing your code to npm for your use or anyone else; not accepting it here is not preventing you from using what you like :) Just publish your module, make use of it. |
In fact, here is an already published module that should meet your needs, and looks like it has some more features that you could make use of: https://www.npmjs.com/package/express-static-gzip |
Functionally, it's ok... In my opinion, pre-compression file serving should be considered to be a part of a static server. Though express-static-gzip is built upon serve-static, but its implementation is redundant. express-static-gzip has done several same logic as serve-static to extend functionality, and it's not eligant. If you insist not to integrate pre-compression file serving, would you expose some mechanism to extend serve-static itself? |
If you think that module can be improved, please open a PR or issue to it, just like you did here. |
#133