Coder Social home page Coder Social logo

Comments (10)

dougwilson avatar dougwilson commented on May 5, 2024

It works just fine. Everything there is a content type issue it's because the install is corrupted on your disk. Please follow the instructions at #35 (comment) and let me know how it goes.

from compression.

FGRibreau avatar FGRibreau commented on May 5, 2024

@dougwilson nope, already did it, did not worked.
I downgraded express to see where it fails and it fails exactly at 4.10.0. compression works well with < 4.10.0

from compression.

dougwilson avatar dougwilson commented on May 5, 2024

Ok. I mean, I and thousands of others use it just fine and this middleware doesn't use anything from express. Can you post an example app that doesn't work with the request to make?

from compression.

FGRibreau avatar FGRibreau commented on May 5, 2024
'use strict';

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

var app = express();

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// app.use(compression());

app.use('/', (function () {
  // I added this IIFE on purpose to demonstrate you without any JS require
  var express = require('express');
  var router = express.Router();

  /* GET home page. */
  router.get('/', function (req, res, next) {
    res.render('index', {});
  });

  return router;
})());

http.createServer(app).listen(8080);

Request header:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
....

Response header:

Connection:keep-alive
Content-Length:36
Content-Type:text/html; charset=utf-8
Date:Sat, 18 Apr 2015 15:22:04 GMT
ETag:W/"24-ae57b51"
Vary:Accept-Encoding
X-Powered-By:Express

from compression.

dougwilson avatar dougwilson commented on May 5, 2024

I just pushed up the branch test-expres-4.12 to this repo which changes every test to use Express 4.12.2 instead of just the plain Node.js HTTP server. Every tests passes with Express 4.12.2: https://travis-ci.org/expressjs/compression/builds/59037148

Feel free to pull down that branch and run it on your machine. If that same branch fails there, you have a corrupted install. If it passes, then it may be some kind of conflict in your existing server code that was brought out with Express.

from compression.

dougwilson avatar dougwilson commented on May 5, 2024

@FGRibreau your example isn't useful since I cannot run it without the views. Can you simplify it more? Also, I know we posted at the same time, but please also run that scenario above to see what you get.

from compression.

FGRibreau avatar FGRibreau commented on May 5, 2024

views/index.jade:

html
  body
    p test

I'm sorry I don't have the time to go further (for now)

from compression.

dougwilson avatar dougwilson commented on May 5, 2024

@FGRibreau that view's response is not compressed because it's under 1KB in size (see the https://github.com/expressjs/compression#threshold option in the readme). By default we don't compress anything below 1KB, since doing so is useless and sometimes even makes the file bigger instead of smaller.

If you really want that view to be compressed, you can change the threshold option.

from compression.

FGRibreau avatar FGRibreau commented on May 5, 2024

Indeed, I already changed threshold to 0 but at that time it did not worked on my original code, I removed a lot of express middleware since and now it works, thanks

from compression.

dougwilson avatar dougwilson commented on May 5, 2024

Ah, I see. It's possible there is a conflict somewhere. Even if it's not a middleware I own, if you find which one is conflicting, please let me know, because I'd like to take a look into it to see if it's something I need to change or the other middleware does.

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.