Problems with gzip when using IIS 7.5 as an Origin server for a CDN

I recently decided to try out my friend Sajals new CDN service over at Turbobytes. While seting this up he pointed out some issues i had with my custom origin domain that i run on IIS. Apparently IIS has some problems that many CDN doesn’t like.

The “Via” Header

To begin with many CDNs send a “Via” header to notify the server that they are a proxy. And for some reason IIS doesn’t  serve gziped content to a server that does this. This means that many CDNs just doesn’t get gziped content from IIS and therfore doesn’t serve gziped content to your customer. To resolve this you have to change some settings in your applicationHost.config.

The thing to fix the problem with the “Via” header is the two attributes noCompressionForHttp10=”false” and noCompressionForProxies=”false” and they kind of explain themselves. And remember the weirdness with the applicationHost.config to not open them in Notepad++ or any other 32bit based apps. You must edit them with a 64 bit text editor like the built in notepad in Windows.

IIS doesn’t return the first request gzip by default

Another issue with IIS as a origin server is that it doesn’t return the first request of a file as gziped. I suppose they figured that for a normal user it’s faster to just return the content and then serve the gziped version to the next user. But a CDN of course only do one request for the file and then sits happy and serving that file. And if that file is not gziped then it will stay not gziped. But there is a fix for this as well. Just modify the same section in applicationHost.config as you’ve edited before and you should be fine. I got lot’s of help in this question on Stack Overflow.

The “Vary” Header

Another possible issue is that IIS doesn’t return a “Vary” header if the content is not gziped. This could cause issues if the first request to your file from any client doesn’t request a gziped file. Since the vary header is not set then the CDN doesn’t try to fetch a new file. As far as i understand it. I just added a custom header to my web.config. The problem with this is that it ads multiple values in the Vary header when i request gziped content. I don’t know if this is a problem or not. I’ve asked a question about this on Stack Overflow. Will update here when i get some more answers to this.

Problem with multiple Vary values.

 

One Thought on “Problems with gzip when using IIS 7.5 as an Origin server for a CDN

  1. That is straight to-the-point article. Thanks. I came here looking for a solution as i am using cloudfront with IIS 7.5 and never got the compression to work.
    The noCompressionForHttp10=”false” and noCompressionForProxies=”false” do the trick. Infact CLoudfront has also mentioned this on their site.

    But the other point about threshold was missing there.
    This has helped. Thanks.

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Post Navigation