Giter Site home page Giter Site logo

Comments (8)

dougwilson avatar dougwilson commented on April 26, 2024

Hi! Your code above works perfectly for me, but since you didn't provide a static file to use, I cannot help much further.

Compression depends on three main things you didn't provide:

  1. What are the request headers you are sending to the server?
  2. What is the type of the file you are serving?
  3. What is the size of the file?

from compression.

davoam avatar davoam commented on April 26, 2024

Thank you for response. Here is curl of request

curl "http://my-server.com.angular.js" -H "Pragma: no-cache" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36" -H "Accept: */*" -H "Referer: http://my-server.com/" -H "Connection: keep-alive" -H "Cache-Control: no-cache" --compressed

And response:

Accept-Ranges:bytes
Cache-Control:public, max-age=0
Connection:keep-alive
Content-Type:application/javascript
Date:Mon, 25 May 2015 21:32:56 GMT
Etag:W/"e90aa-1077232132"
Last-Modified:Mon, 25 May 2015 21:09:53 GMT
Server:Cowboy
Transfer-Encoding:chunked
Vary:Accept-Encoding
Via:1.1 vegur
X-Powered-By:Express

from compression.

dougwilson avatar dougwilson commented on April 26, 2024

Thank you. How big is the file (in bytes). By default we will not compress a file if it under 1kb. I can also see by your response you have a proxy between you and the server. This is the problem pretty much 100% of the time. Can you make the request directly to the server without going through the proxy?

from compression.

davoam avatar davoam commented on April 26, 2024

The size of file is 958KB. It does not work even if run node index.js on my computer

from compression.

dougwilson avatar dougwilson commented on April 26, 2024

Unfortunately everything works perfectly for me with the code you sent. This means that I will just have to await a PR from you that fixes the issue, unfortunately. I will await a PR with the fix :)

from compression.

dougwilson avatar dougwilson commented on April 26, 2024

I'm going to close this for now due to lack of reproduction. If you are able to figure out the issue and it turns out to be a bug in this module, a PR would be very welcome :) Here is the console session from when I tried to reproduce the issue with the information provided:

$ cat app.js
var express = require('express');
var compression  = require('compression');
var app = express();

app.set('port', (process.env.PORT || 5000));
app.use(compression());
app.use(express.static(__dirname + '/public'));

app.listen(app.get('port'), function() {
  console.log("Node app is running at localhost:" + app.get('port'));
});

$ node -v
v0.10.33

$ npm i compression express
[email protected] node_modules\compression
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])

[email protected] node_modules\express
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected])

$ mkdir public

$ node -pe 'console.log("/* " + new Buffer(958 * 1024) + " */")' > public/example.js

$ ls -lh public/
total 480k
-rw-r--r--    1 user     group     958k May 25 17:59 example.js

$ node app.js &
[1] 14108
Node app is running at localhost:5000

$ curl -XGET -I -H'Accept-Encoding: gzip, deflate, sdch' http://localhost:5000/example.js
HTTP/1.1 200 OK
X-Powered-By: Express
Accept-Ranges: bytes
Date: Mon, 25 May 2015 22:03:32 GMT
Cache-Control: public, max-age=0
Last-Modified: Mon, 25 May 2015 21:59:33 GMT
ETag: W/"ef815-3318529146"
Content-Type: application/javascript
Vary: Accept-Encoding
Content-Encoding: gzip
Connection: keep-alive
Transfer-Encoding: chunked

Please try to follow my console session above yourself to see if it reproduces for you. If following the above still shows Content-Encoding: gzip in the response like mine does, then it didn't reproduce the issue. If there are adjustments you can make that reproduce it, please feel free to follow up with the full instructions to reproduce, in the format as above so I can reproduce.

from compression.

davoam avatar davoam commented on April 26, 2024

ok, thank you. I'll try

from compression.

joshmarinacci avatar joshmarinacci commented on April 26, 2024

I've had the same problem as well. Your test script worked for me, however. The difference seems to be using -XGET in the curl command. According to this page:
http://stackoverflow.com/questions/8498371/curl-get-and-xget

the difference is that -XGET forces curl to use a GET request. By default it is doing a HEAD request, which I guess doesn't get gzipped.

So it looks like compression is turned on, it just doesn't appear to be thanks to curl. Could you include instructions for using curl properly to verify gzip in the readme?

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.