IIS: Enable Compression for HTTP 1.0 Request
Recently I was integrating Amazon CloudFront CDN in this blog. During the integration I found that default IIS configuration do not compress static resource when requested with HTTP 1.0. So in this quick & short post we will see how to enable static resource compression for HTTP 1.0 request in IIS.
In amazon, I have configured IIS 8.0 as a custom origin server and uploaded static resource over there. During configuration I noticed that CloudFront endpoint was serving an un-compressed static resource I was bit surprise because in CloudFront documentation, it is mentioned that it will forward request header to origin server as well response header back to requestor/client i.e. web browser here. To verify, I opened fiddler and requested static resource directly from origin server i.e. IIS 8.0. As I assumed IIS returned compressed response and appropriate response header. I was bit puzzled where to configure CloudFront to serve compressed resource as in CloudFront console I do not find any specific settings related to compression because as per documentation it was as easy as forwarding request header to origin server and forwarding response header back to requestor.
Suddenly I decided to look into IIS log and I found that Amazon CloudFront uses HTTP 1.0 to request custom origin server.
I did not expected HTTP 1.0 request here so once again I requested origin server with HTTP 1.0 using fiddler and as a surprise IIS returned un-compressed response. In IIS by default compression for HTTP 1.0 request is disabled. We need to explicitly enable compression for HTTP 1.0 request. To Enable compression for HTTP 1.0 request we need to change web.config as below.
<httpCompression noCompressionForHttp10="false" noCompressionForProxies="false"></httpCompression>
After changing web.config as above, IIS started to server compressed response for HTTP 1.0. Hope this quick and short post would be helpful!