Nicholas Head

Filter by APML

Getting application/x-javascript to compress in IIS7

by Nicholas Head 29. September 2008 07:19

Tonight I set about trying to get my IIS7 server to serve files with the application/x-javascript content type as compressed. After a bunch of testing, back and forth, ultimately this is what worked for me in my applicationHost.config file:

<dynamicTypes>  
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/x-javascript; charset=utf-8" enabled="true" />
    <add mimeType="application/x-javascript" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</dynamicTypes>

You have to be specific it seems, specifying the charset. And it needs to go before the regular x-javascript entry. Go figure. Hopefully this saves someone else some headaches.

Also, while you’re tinkering with applicationHost.config, you might as well change this:

<serverRuntime />

Into this:

<serverRuntime frequentHitThreshold="1" />

That specifies that IIS7 should compress/cache any static content the first time it’s requested. Otherwise, it defaults to “2”, which means it will only cache the compressed content if it’s requested at least 2 times within 10 minutes.

Bookmark and Share

Tags:

IIS7 | Microsoft

Are you moving or looking to move soon? Don't hurt your back shifting boxes around-- use HireAHelper to Book Movers Online!

Log in

Powered by BlogEngine.NET 1.6.1.0