Skip to content

Codepolice

  • ⤫

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

Posted by Judy Alvarez Posted on February 28, 2022March 2, 2022
0

I recently decided to try out my friend Sajals new CDN service over at Turbobytes. While setting this up he pointed out some issues I had with my custom origin domain that I run on IIS. 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 gzipped content to a server that does this. This means that many CDNs just don’t get gzipped content from IIS and therefore don’t serve gzipped content to your customer. To resolve this you have to change some settings in your applicationHost.config.

<location path="Your Site">
<system.webServer>
<httpCompression noCompressionForHttp10="false" noCompressionForProxies="false" />
</system.webServer>
</location>

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.

curl -I -H Accept-Encoding:gzip,deflate -H Via:Cdn http://example.com/test.css

HTTP/1.1 200 OK
Content-Length: 5648
Content-Type: text/css
Content-Encoding: gzip
Last-Modified: Thu, 14 Jul 2011 16:56:26 GMT
Accept-Ranges: bytes
ETag: "add123f84642cc1:0"
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Date: Mon, 25 Jun 2012 13:01:34 GMT

IIS doesn’t return the first request gzip by default

Another issue with IIS as an origin server is that it doesn’t return the first request of a file as gzipped. I suppose they figured that for a normal user it’s faster to just return the content and then serve the gzipped version to the next user. But a CDN of course only do one request for the file and then sits happy and serves that file. And if that file is not gzipped then it will stay not gzipped. 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 lots of help with this question on Stack Overflow.

    <location path="Your Site">
       <system.webServer>
        <httpCompression noCompressionForHttp10="false" noCompressionForProxies="false" />
	<serverRuntime
          frequentHitThreshold="1"
          frequentHitTimePeriod="00:00:05" />
       </system.webServer>
    </location>

The “Vary” Header

Another possible issue is that IIS doesn’t return a “Vary” header if the content is not gzipped. This could cause issues if the first request to your file from any client doesn’t request a gzipped 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 gzipped content. I don’t know if this is a problem or not. I’ve asked a question about this on Stack Overflow. I will update here when I get some more answers to this.

<httpProtocol>
<customHeaders>
<remove name="Vary"></remove>
<add name="Vary" value="Accept-Encoding" />
</customHeaders>
</httpProtocol>
curl -I http://example.com/test.css

HTTP/1.1 200 OK
Content-Length: 18241
Content-Type: text/css
Last-Modified: Thu, 14 Jul 2011 16:56:26 GMT
Accept-Ranges: bytes
ETag: "add123f84642cc1:0"
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Date: Tue, 26 Jun 2012 12:04:42 GMT

Problem with multiple Vary values.

curl -I -H Accept-Encoding:gzip,deflate http://example.com/theme.css
HTTP/1.1 200 OK
Content-Length: 4445
Content-Type: text/css
Content-Encoding: gzip
Last-Modified: Thu, 14 Jul 2011 16:56:26 GMT
Accept-Ranges: bytes
ETag: "059d5f74642cc1:0"
Vary: Accept-Encoding,Accept-Encoding
Server: Microsoft-IIS/7.5
Date: Tue, 26 Jun 2012 12:03:00 GMT
Categories: JavascriptTagged: asp net 3.5, asp net authorization, asp net barcode generator, asp net book pdf, asp net core crud operations example, asp net core vs asp net framework, asp net development agencies, asp net framework vs core, asp net generate pdf from html, asp net grid, asp net identity core, asp net interview questions and answers for experienced, asp net jobs in bangalore, asp net mvc caching, asp net mvc development company, asp net mvc sample application, asp net mysql, asp net pdf report generation, asp net rapid application development, asp net sending e mail, asp net the complete reference by matthew macdonald pdf free download, asp net vb net, asp net vs vb net, asp net web development india, asp net web forms tutorial c#, difference between asp net and asp net mvc, editable gridview in asp net, hcso hctx net inmateinfo asp, master page in asp net, what is cms in asp net

Post navigation

Previous Previous post: Query the MySQL / WordPress Database from an ASP.NET site
Next Next post: What I Love So Far With Visual Studio

Related Posts

  • TypeScript and JavaScript dominate on GitHub in 2025

    #​759 — October 31, 2025 Read on the Web JavaScript Weekly Directives and the Platform Boundary — First there was the “use strict” directive to opt in to strict mode in JavaScript, but now you’ll encounter use client, use server, React’s new use no memo, and more, and they’re not standard JS features at all.

    Posted by Posted on October 31, 2025
    0
  • The reality of porting Deno code to Node

    #​598 — October 28, 2025 Read on the Web Awesome Node: Over 500 Curated Packages, Resources and Links — It’s been more than four years since we linked to Sindre’s handy resource, but it continues to get updates and tweaks (and, if you want, you can contribute a submission too – though the bar is

    Posted by Posted on October 28, 2025
    0
  • Vitest 4.0 and Next.js 16

    #​758 — October 24, 2025 Read on the Web JavaScript Weekly Vitest 4.0 Released: The Vite-Native Testing Framework — The Vite-powered, Jest-compatible testing framework introduces visual regression testing, makes its ‘Browser Mode’ stable (for running tests in a browser directly), adds Playwright Traces support, and more. Still unsure? You can compare it with other test

    Posted by Posted on October 24, 2025
    0
  • Node.js 25.0 arrives

    #​597 — October 21, 2025 Read on the Web Node.js v25.0.0 (Current) Released — The latest cutting edge version of Node has arrived with Web Storage enabled by default, JSON.stringify perf improvements, a new –allow-net option in the permission model, built-in Uint8Array base64/hex conversion, and WebAssembly and JIT optimizations. As shown in the diagram above, this

    Posted by Posted on October 21, 2025
    0
  • A Bun-believable release that isn’t half-baked

    #​757 — October 17, 2025 Read on the Web JavaScript Weekly Bun 1.3: The Full-Stack JavaScript Runtime — Arriving a few hours after last week’s issue (natch!) Bun 1.3 remains the big news of the past week. Bun is a performance and DX-focused JavaScriptCore-powered runtime which, with v1.3, balances being a drop-in Node.js replacement with

    Posted by Posted on October 17, 2025
    0
  • Bringing Python apps into Node

    #​596 — October 14, 2025 Read on the Web 📂 A Modern Guide to Reading and Writing Files in Node — A comprehensive guide to various methods for working with files, from promise-based methods through to working with streams, processing files concurrently, using file handles, and memory-efficient techniques. Luciano Mammino A Way to Integrate Python ASGI with Node.js

    Posted by Posted on October 14, 2025
    0
Judy Alvarez

Leave a Reply Cancel reply

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

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • TypeScript and JavaScript dominate on GitHub in 2025
  • The reality of porting Deno code to Node
  • Vitest 4.0 and Next.js 16
  • Node.js 25.0 arrives
  • A Bun-believable release that isn’t half-baked
https://flatlogic.com/generator
COPYRIGHT © 2025 - Codepolice