How to not gzip certain files ? #55

Open
pinouchon opened this Issue Feb 28, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@pinouchon

I have an issue where gzippo overrides the http headers, and it causes my html files to never refresh.

For example:

express.js:

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

app.configure(function () {
  app.use(function (req, res, next) {
    res.setHeader('foo', 'bar');
    return next();
  });
});

var connect = require('connect');
connect.createServer(
  connect.static("" + __dirname + "/dist")
).listen(8090);

gzippo.js

var gzippo = require('gzippo');
var express = require('express');
var app = express();

app.configure(function () {
  app.use(function (req, res, next) {
    //res.set('Cache-Control', 'public, max-age=0');
    //res.set('X-Powered-By', 'Express');
    res.set('X-Powered-By', '')
    res.set('Accept-Ranges', 'bytes');
    res.set('ETag', '"50-1393582560000"');
    res.set('Date', 'Fri, 28 Feb 2014 10:35:50 GMT');
    res.set('Cache-Control', 'public, max-age=0');
    res.set('Last-Modified', 'Fri, 28 Feb 2014 10:16:00 GMT');
    res.set('Content-Type', 'text/html; charset=UTF-8');
    res.set('Content-Length', '50');
    res.set('Connection', 'keep-alive');
    return next();
  });
});

//var logFile = fs.createWriteStream('./myLogFile.log', {flags: 'w'}); //use {flags: 'w'} to open in write mode
//app.use(express.logger({stream: logFile}));

app.use(express.logger('dev'));
//app.use(gzippo.staticGzip("" + __dirname + "/dist", {maxAge: 0, clientMaxAge: 0}), {maxAge: 0, clientMaxAge: 0});
app.use(gzippo.staticGzip("" + __dirname + "/dist", {maxAge: 0, clientMaxAge: 0}), {maxAge: 0, clientMaxAge: 0});

app.listen(8090);
  • Launch node express.js. Get an html file and inspect headers. (in chrome, and with curl -I)
  • Launch node gzippo.js. Get an html file and inspect headers. (in chrome, and with curl -I)

You will see that chrome will override max-age: 0 for the gzippo server. Why is that ?


In my case, it would be great to specify to my gzippo server not to gzipo html files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment