expressjs / compression

Node.js compression middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compression not working in Heroku

cythilya opened this issue · comments

I have gzip when I run "yarn run dev" in local, but after I run "heroku local" or deploy my app to Heroku, gzip is gone. Below are my code snippet.

package.json

"compression": "^1.7.3",
"express": "4.16.2",

server.js

const server = express();
server.use(compression());

or view my repo and demo.

Can you provide a specific example URL to call so I can test the same one (since there are lots of URLs in that app)?

Please view this url.

When I run in local "yarn run dev"

2018-09-12 10 09 28

After I deploy my app to Heroku

2018-09-12 10 10 04

Yea, I'm also not seeing it as compressed. Is there a way to attach a debugger into the running code on Heroku to see what is happening?

Same here, my assets are not being compressed and they are reported by google page speed as not compressed :)

CSS and JS files are being compress, everything else, is not. Weird.

Using:

"compression": "^1.7.3",
"express": "^4.16.3",
"node": "8.10.0"

Here is my site.

If you check the network panel, you'll see how the only assets being compressed are CSS & JS file. Fonts, svgs, etc are not.

This is how I use the module:
captura de pantalla 2018-09-13 11 11 49

Thanks

Actually, this problem is not related to Heroku, as in local the same results are outputted on the network tab.

So, its reproducible also in local environments.

Hi @Avcajaraville sorry to hear you're having the same issue. I would live to debug through the issue to get to a resolution. Can you provide code and steps to reproduce so I can examine?

@dougwilson I just set a minimum gist that reproduces the issue here

As you can see, the css file is being gzip, while the svg is not:
captura de pantalla 2018-09-13 18 58 38
captura de pantalla 2018-09-13 18 58 50

Ah, thanks @Avcajaraville ! This is because the SVG file in your example does not exceed the default value for the threshold option (https://github.com/expressjs/compression#threshold) which is 1kb. Responses below that threshold size are not compressed. You can lower the threadshold if you need it compressed 👍

Thanks a lot @dougwilson that was a super useful and quick answer :)

This is also the reason why this is not working for @cythilya.

We should read the docs more carefully :)

Really nice response time and great job with this module !!

It's no problem! Happy to help.