Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Support gzip static serving #134

wants to merge 2 commits into from

Conversation

licg9999
Copy link

@licg9999 licg9999 commented Mar 14, 2020

@dougwilson
Copy link
Contributor

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.

@dougwilson dougwilson closed this Mar 14, 2020
@dougwilson dougwilson added the pr label Mar 14, 2020
@licg9999
Copy link
Author

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.

@dougwilson
Copy link
Contributor

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.

@licg9999
Copy link
Author

If all static file serving should be done by NGINX / Apache, then why should expressjs/serve-static be there?
In some simple situation or non-production environment, expressjs/serve-static is a good option, but now I have to setup another file server to go on. It's not proper for me at all.

@dougwilson
Copy link
Contributor

dougwilson commented Mar 14, 2020

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.

@dougwilson
Copy link
Contributor

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

@licg9999
Copy link
Author

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?

@dougwilson
Copy link
Contributor

If you think that module can be improved, please open a PR or issue to it, just like you did here.

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

Successfully merging this pull request may close these issues.

2 participants