Skip to content

Instantly share code, notes, and snippets.

@geddski
Created December 14, 2012 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geddski/4289625 to your computer and use it in GitHub Desktop.
Save geddski/4289625 to your computer and use it in GitHub Desktop.
example of using express middleware to gzip xml files
var express = require('express');
var connect = require('connect');
var zlib = require('zlib');
var fs = require('fs');
var app = express();
var compressOptions = {
filter: function(req, res) {
return /json|text|xml|javascript/.test(res.getHeader('Content-Type'))
}
};
app.use(express.compress(compressOptions));
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res){
res.sendfile('./public/data.xml');
});
app.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment