6

Today 1.0 of socket.io has been released. I just updated and now the following isn't working anymore:

io.enable('browser client minification');
io.enable('browser client etag');
io.enable('browser client gzip');

The new documentation seems not to be complete yet, how to minify and enable gzip+etag with 1.0 ?

4 Answers 4

7

It seems this is not possible with 1.0 - recursive search in the socket.io folder with words like "gzip", "etag", and "minif" does not provide any relevant results. Besides in previous versions there was a socket.io.min.js file near socket.io.js. Now it is absent.

Maybe the following solution is not satisfying, but in case you're using nginx (or other webserver) in front of node you can serve socket.io.js (manually compressed by Google Closure Compiler for example) with your own. You can enable gzip and etag on nginx as well.

1
5

Check this out: http://socket.io/blog/introducing-socket-io-1-0/

CDN delivery

One of the best decisions we made early on was that implementing a Socket.IO server would not only give you access to the realtime protocol, but Socket.IO itself would also serve the client.

Normally, all you have to do is to include a snippet like this:

<script src="/socket.io/socket.io.js"></script>

If you want to optimize access to the client by serving it near your users, provide the maximum level of gzip compression (thanks to Google’s zopfli and proper support for caching, you can now use our CDN. It’s free, forever, and has built-in SSL support:

<script src="https://cdn.socket.io/socket.io-1.0.0.js"></script>

Also, if you are migrating from 0.9: http://socket.io/docs/migrating-from-0-9/

1
  • If you host a local socket IO enabled service such as Etherpad then your nearest Socket IO instance is local. With that in mind a CDN is a bad idea. Nov 19, 2014 at 0:52
2

About compression:

Looking at the old code for version 0.9 it seems to be spawning gzip processes to do the compression. I cannot find any caching neither.

We haven't noticed any significant slowdown on production because of that so maybe it does something smart at some point but I am not that surprised that they removed all this code.

Minification was using uglify before:

The sample from https://cdn.socket.io/socket.io-1.0.0.js is 78.5 kB, a minified version comes to 57.1 kB. 37% more but negligible when you compare that with the amount of data that will be transferred through it.

1
  • I can gzip through nginx reverse proxy but no minified version :/ Thanks for your answer tho.
    – Daniel W.
    Sep 29, 2014 at 11:50
1

I used CDN but I had cross origin domain problems with firefox.

Actually that problem happen because socket.io starts in firefox with xhr-polling transport method and, immediately after, it switchs to websocket, instead chrome starts directly with websocket. Setting as first transport method websocket (by client js configuration) the problem was fixed, but what about clients that not support websocket yet ? So i returned back to node serverd version.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.