Giter Site home page Giter Site logo

Comments (10)

ORESoftware avatar ORESoftware commented on April 17, 2024

well technically it wouldn't be a separate thread, it would be a separate Node.js process I guess, and this seems unlikely. So how does compression not slow down your server then?

from compression.

dougwilson avatar dougwilson commented on April 17, 2024

This library simply uses Node.js's zlib library. Node.js uses a thread pool for compression, encryption, file I/O and DNS lookups. You can find out more details by asking the Node.js core team for how the asynx zlib functionality works, if you wish, as they would be able to explain it much better than myself.

But to sum it up: the operations run in a thread pool in the Node.js process.

from compression.

dougwilson avatar dougwilson commented on April 17, 2024

Here is a link to a thread with the answer on the Node.js mailing list, answered by a core committer: https://groups.google.com/forum/#!topic/nodejs/WR4coxriQSM

from compression.

ORESoftware avatar ORESoftware commented on April 17, 2024

thanks that's great info

from compression.

dougwilson avatar dougwilson commented on April 17, 2024

No problem!

from compression.

ORESoftware avatar ORESoftware commented on April 17, 2024

hey Doug, here is my question of the hour - the way this is set up it will compress files for every request. so if a client A requests a text based asset, Express will compress it and then serve it. When client B comes around and requests the same asset, it will do the same thing over again. Is there a way to GZIP assets with ZLIB before the server starts?

from compression.

ORESoftware avatar ORESoftware commented on April 17, 2024

in other words, is there a way to either

(1) cache the results of gzip process (saving .gz files onto server) during server runtime
(2) write out .gz file(s) onto the server before it starts up

it seems like (2) is a much better idea, especially since I personally really only have one production file to deploy, I can just gzip the one file before the server starts and then point to a .gz file instead of a .js file in my index .html file.

from compression.

ORESoftware avatar ORESoftware commented on April 17, 2024

I just saw the question about caching from another user, so I opened up a new issue/question. Hopefully the new question/issue I asked is a good one, probably better to answer the question over there than here. I can move/delete the comments from the last hour on this thread into the new issue.

from compression.

dougwilson avatar dougwilson commented on April 17, 2024

Hi! There certainly is, though not with this module (which is simply on-the-fly compression, meant for dynamic content rather than static content). There are other modules on npm just for the specific purpose of doing this with static files (typically your pre-compress with a grunt/gulp task and then serve with a specialized module).

from compression.

ORESoftware avatar ORESoftware commented on April 17, 2024

ok thanks! I guess I can add the names to those modules to this thread later, it all makes sense and I appreciate the info

from compression.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.