Use gzip (or something else) to serve compressed responses


#1

It was so much a given for me that I always assumed that compression was handled somewhere. But I’ve just realized it was not the case.

What’s your strategy to enable it ? I know it’s not that much… but still.


#2

When you run your Meteor application in Dev environment (meteor run) then you have no compression.
But after you deploy your app (meteor deploy foo.meteor.com) then HTTP compression is activated.
You can check this with the dev tools of your favorite web browser.


#3

The WebSockets permessage-deflate (zip) is enabled by default since version 1.2.

If it is necessary, you can customize to another type of compression:

News link:

“Websockets now support the permessage-deflate extension, which compresses data on the wire. It is enabled by default on the server. To disable it, set $SERVER_WEBSOCKET_COMPRESSION to 0. To configure compression options, set $SERVER_WEBSOCKET_COMPRESSION to a JSON object that will be used as an argument to deflate.configure. Compression is supported on the client side by Meteor’s Node DDP client and by browsers including Chrome, Safari, and Firefox 37.”


#4

Please show me a link where it’s activated.

https://www.meteor.com/ does not use gzip on the document. content-encoding:gzip clearly does not appear in the response header.

.js and .css are served gziped in that case, but only because they are served from cloudfront. When you deploy an app with meteor deploy, they are not.


#5

You can have a look at my application: crystal.meteor.com
According to Google Chrome, the javascript file has “content-encoding:gzip” in its response header.
Also, Chrome says “227 KB transferred”, but when I download the JS files, it weights 820 KB.
The difference comes from the compression.


#6

Here’s what I obtain on your application

And this checking application agrees : http://checkgzipcompression.com/?url=http%3A%2F%2Fcrystal.meteor.com%2Fcards

No gzip.


#7

But you are only talking about the HTML document here, which is almost empty (1 KB)
There is no point to compress it.
The important point is to compress the Javascript file and the CSS.


#8

Except when you go full SSR and that your HTML weight more than 200 ko.

=> http://zelip.co/