Gzip for http requests

900 views
Skip to first unread message

Wizermil

unread,
Dec 30, 2010, 5:13:16 PM12/30/10
to Express
Hi,

I was playing with you excellent framework (fast+easy, congrats) to
learn more about node.js and make some test to see by myself how fast
is node.js. After few minutes playing with "Hello World" I was looking
for a gzip module like in webservers to decrease the bandwidth but I
didn't find it in the documentation.

Do you plan to add this feature to express ?

BTW, I saw that there are few modules available for node.js maybe I
could help you adding this new feature in the framework. I didn't
really checked the code yet but I'm pretty sure that it won't take
long to implemented based on the existing code, do you have any
advices that could help me to add this feature ?

Regards,

Mathieu

vision media [ Tj Holowaychuk ]

unread,
Dec 30, 2010, 5:22:33 PM12/30/10
to expre...@googlegroups.com
We have some gzip related middleware in Connect, however I do not personally recommend them. They waste more (in most cases) than you will gain from them


--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.




--
Tj Holowaychuk
Vision Media
President & Creative Lead

Andrew Peace

unread,
Dec 30, 2010, 5:51:33 PM12/30/10
to expre...@googlegroups.com
Hi Mathieu,

I think this will do the trick for you:

var express = require('express'),
app = express.createServer();

app.use(express.gzip());

app.get('/', function(req, res) {
res.send('This page is totally Gzipped!!');
});

Express is based on Connect, which uses some cool middleware, like
their gzip() middleware (express.gzip() is just a reference to the
Connect function). Check out this page for more reading on middleware:
http://expressjs.com/guide.html#Middleware

But Tj is right. Node is so fast at serving requests that I've never
found this middleware to benefit me greatly. I do, however, love the
staticGzip middleware for serving gzipped static content. You can see
an example of the staticProvider middleware (which is identical in
API) here: http://expressjs.com/guide.html#Configuration

-- Andrew Peace

vision media [ Tj Holowaychuk ]

unread,
Dec 30, 2010, 6:20:54 PM12/30/10
to expre...@googlegroups.com
Yeah I wrote the staticGzip one to prevent the overhead for static files which are usually larger anyways, BUT we (and most apps) ship them off to a cdn anyways, so we just pipe through gzip and ship it off to s3 anyways and dont touch any of the gzip middleware

Wizermil

unread,
Dec 31, 2010, 9:52:50 AM12/31/10
to Express
Hi,

Thanks a lot for the answers.

Node.js is awesome !!! I'll have a lot to learn about express/comet
and node but it's really existing comparing to php. I spent the day
reading/watching/compiling and testing and I had a lot of fun.

Cheers,

Mathieu

On Dec 31, 12:20 am, "vision media [ Tj Holowaychuk ]" <t...@vision-
media.ca> wrote:
> Yeah I wrote the staticGzip one to prevent the overhead for static files
> which are usually larger anyways, BUT we (and most apps) ship them off to a
> cdn anyways, so we just pipe through gzip and ship it off to s3 anyways and
> dont touch any of the gzip middleware
>
>
>
>
>
>
>
>
>
> On Thu, Dec 30, 2010 at 2:51 PM, Andrew Peace <ape...@gmail.com> wrote:
> > Hi Mathieu,
>
> > I think this will do the trick for you:
>
> > var express = require('express'),
> >    app = express.createServer();
>
> > app.use(express.gzip());
>
> > app.get('/', function(req, res) {
> >    res.send('This page is totally Gzipped!!');
> > });
>
> > Express is based on Connect, which uses some cool middleware, like
> > their gzip() middleware (express.gzip() is just a reference to the
> > Connect function). Check out this page for more reading on middleware:
> >http://expressjs.com/guide.html#Middleware
>
> > But Tj is right. Node is so fast at serving requests that I've never
> > found this middleware to benefit me greatly. I do, however, love the
> > staticGzip middleware for serving gzipped static content. You can see
> > an example of the staticProvider middleware (which is identical in
> > API) here:http://expressjs.com/guide.html#Configuration
>
> > -- Andrew Peace
>
> > On Thu, Dec 30, 2010 at 5:13 PM, Wizermil <mathieu.gar...@gmail.com>
> > wrote:
> > > Hi,
>
> > > I was playing with you excellent framework (fast+easy, congrats) to
> > > learn more about node.js and make some test to see by myself how fast
> > > is node.js. After few minutes playing with "Hello World" I was looking
> > > for a gzip module like in webservers to decrease the bandwidth but I
> > > didn't find it in the documentation.
>
> > > Do you plan to add this feature to express ?
>
> > > BTW, I saw that there are few modules available for node.js maybe I
> > > could help you adding this new feature in the framework. I didn't
> > > really checked the code yet but I'm pretty sure that it won't take
> > > long to implemented based on the existing code, do you have any
> > > advices that could help me to add this feature ?
>
> > > Regards,
>
> > > Mathieu
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Express" group.
> > > To post to this group, send email to expre...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > express-js+...@googlegroups.com<express-js%2Bunsubscribe@googlegrou ps.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/express-js?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Express" group.
> > To post to this group, send email to expre...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > express-js+...@googlegroups.com<express-js%2Bunsubscribe@googlegrou ps.com>
> > .
Reply all
Reply to author
Forward
0 new messages