Search code examples
node.jsnginxsocket.iopagespeedmod-pagespeed

How to use ngx_pagespeed and socket.io?


I use ngx_pagespeed to optimize the performance of my web application. The module works very well with nginx for me. Now i want to use socket.io for "realtime" actions on my web app. Socket.io generated and serves the client libary for compatibility reasons via the URL /socket.io/socket.io.js. So some older browsers get different versions of the client libary than newer ones.

The problem here is, that ngx_pagespeed tries to treat the socket.io.js like a normal JS-file. In conclusion the ngx_pagespeed module dont find the socket.io.js file on the disk and is not able to serve the file to the client. The client get an 404 for the socket.io client library.

So is it possible to use ngx_pagespeed only for some subfolders? Or is it possible to ignore a url e.g. /socket.io/socket.io.js I cant find anything like that in the docs.


Solution

  • Use disallow to exclude it.

    pagespeed   Disallow "*/socket.io*";
    

    https://developers.google.com/speed/pagespeed/module/restricting_urls