title: Serve static gzip files using node.js
body: <p>I don't want to use a library which gzips on the fly, because of the overhead.</p>
  
  <p>The website has some dynamic components which is implemented in node.js.</p>
  
  <p>I have some static js and css files as well as their gzipped counterparts. I want to serve the gzipped version only to browsers which support it.</p>
  
  <p>I considered using the static middleware in express to serve the static files, along with some URL rewriting middleware to conditionally serve the gzipped files. However, I cannot find any conditional rewrite module.</p>
  
  <p>I cannot believe that no one has done this, or that it needs so many work arounds. What am I missing?</p>
  
  <p>On a different note, is serving up static files via node.js too expensive? On the other hand, using Apache for static files and running node.js behind seems bad as well. What is the least stupid configuration for AWS EC2 hosting?</p>