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

Chrome Not Showing Any Compression Occuring #31

Closed
sbryfcz opened this issue Jan 20, 2015 · 3 comments
Closed

Chrome Not Showing Any Compression Occuring #31

sbryfcz opened this issue Jan 20, 2015 · 3 comments
Assignees
Labels

Comments

@sbryfcz
Copy link

sbryfcz commented Jan 20, 2015

I'm having trouble getting compression to work properly. I've tried reading a lot of resources and your issue pages but I'm still stuck. Oddly, when I use services like http://www.whatsmyip.org/http-compression-test/ it shows that the service is compressed. But when I use chrome to simple try and go to the service, I dont see any compression happening. When I turn on DEBUG=compression I see the message

compression gzip compression +8m.

So I'd like to believe it is working, but the response in the browser shows no compression. Any advice would be great and appreciated! Thanks!

I have a seemingly simple test server/service

var compression = require('compression');
var express = require('express');

var app = express();

//turn on compression
app.use(compression({ threshold: 0 }));

// simple get service to get 10000 random numbers
app.get('/events', function (req, res) {
    console.log(req.headers);

    var obj = [];

    for (var i = 0; i < 10000; i++) {
        obj.push({
            number: Math.random()
        });
    }

    res.send(obj);
});

//start the server
var server = app.listen(80, function () {
    console.log('Address', server.address());
    console.log('Listening on port %d', server.address().port);
});

The headers in my req are

    { via: '1.1 DETHQTMG109',
     'user-agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)   Chrome/39.0.2171.95 Safari/537.36',
      host: 'usaievents.cloudapp.net',
      'cache-control': 'max-age=0',
      accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
      'accept-language': 'en-US,en;q=0.8',
      connection: 'Keep-Alive',
      'if-modified-since': 'Tue, 20 Jan 2015 15:21:29 GMT', 
      'if-none-match': 'W/"YxqKyY8MDi7MUoNr2htsjg=="',
      'accept-encoding': 'gzip' 
    }
@dougwilson
Copy link
Contributor

Are you sure you are not behind a proxy when accessing from your machine?

@dougwilson dougwilson self-assigned this Jan 20, 2015
@sbryfcz
Copy link
Author

sbryfcz commented Jan 20, 2015

Wow. Today I learned! Fixed and working fine when I'm not on the proxy. Thanks so much.

@sbryfcz sbryfcz closed this as completed Jan 20, 2015
@dougwilson
Copy link
Contributor

It's no problem :) I was suspicious because you said that compression test site worked and then the request headers you posted had a Via header, which is typically inserted by a proxy. Once a request goes through a proxy, whether or not you see the response is compressed is dependent on the proxy, rather than what the source server did :)

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

No branches or pull requests

2 participants