I have the following setup:

  • Nginx (1.1.19) on the front as a reverse proxy / loadbalancer
  • IIS7 at the back as web servers
  • MySQL as a database

I am trying to figure out whether to compress static resources like JS, CSS etc. and generated HTML with the loadbalancer or with the web servers? Can Nginx pass the already compressed responses it receives from IIS to the client normally or is is better to do the compression on Nginx? If the compression in done with IIS, the traffic between it and and the Nginx would be smaller.

I should of course measure which option is better, but before that, has anyone experience with similar setups? What worked for you and why did you end up in that solution?


  • A new question came to mind: If the IIS serves already compressed content to Nginx doesn't this mean that Nginx uses less memory for buffering (wiki.nginx.org/HttpProxyModule#proxy_buffers)? At least according to book "Mastering Nginx" pages 101-104 it could be deduced so. E.g. if I have 8x128kB = 1024kB proxy buffers and the response from the proxy is 1536kB then the buffer becomes full and 512kB worth gets written to disk. But if I can compress the response under 1024kB, then none is written to disk and the smaller it is, the less memory it consumes. Jul 10, 2013 at 11:17
  • We decided to do the compression with IIS. noCompressionForHttp10 and noCompressionForProxies settings were relevant in order to make the compression work with Nginx. See serverfault.com/questions/23788/… and iis.net/configreference/system.webserver/httpcompression Jul 26, 2013 at 7:23

2 Answers 2


You should keep this on the webserver, as a Load Balancer is usually (should be) optimized to do just that, not for modifying content.

Of course you can do it on the LB, but you most likely would need to beef it up a lot - resources which are of more use at the webserver. IMO.


There's often no benefit in using compression inside LAN due to increased latency and enough bandwidth margin anyway, but when it casts traffic out — to Internet, it makes sense. Also, backend usually is being saved from extra-work and this is the second reason to use nginx for compression instead of IIS.

Your Answer

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

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