Comments (10)
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.
@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.
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.
'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);
└── [email protected]
└── [email protected]
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.
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.
@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.
views/index.jade
:
html
body
p test
I'm sorry I don't have the time to go further (for now)
from compression.
@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.
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.
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)
- Setting Vary header although caching is disabled HOT 1
- "drain" event listener leak when using res.once("drain"); can't use res.removeListener("drain") HOT 3
- compresssion doesn't work ,the vue.txt is 2m HOT 2
- Content-Type: application/json; charset=utf-8 No effect HOT 2
- Question: Why this middleware HOT 2
- Corrupted compressed .js-files for Mac OS / Safari -clients HOT 11
- Is compression working when node server is running on a container? HOT 2
- middleware fails when the request has more than 1 values for accept-encoding header HOT 2
- Is compression result cached? HOT 1
- change Transfer-encoding HOT 1
- Why does the data size increase after compression HOT 1
- Force size to be a minimum... HOT 2
- Chunked encoding is broken after using this middleware HOT 1
- Using a current debug version HOT 1
- Deflate backwards HOT 7
- Compression instrumentation (before/after compression hooks) HOT 2
- Angular Not Compressing? HOT 2
- compression not working json payload HOT 6
- Crash when compressing characters like ū HOT 1
- Express returns a non-compliant HTTP/206 response when gzip is enabled HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compression.