Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If anyone can help it would be appreciated. I would like to enable compression for static files within IIS7 (for the sake of simplicity I'll just refer to static css files for the time being).

The problem I'm getting is that css files are only compressed when both dynamic and static compression is enabled in IIS for the website. What I really want to achieve is css compression (static file) whilst leaving the dynamic (aspx) pages as uncompressed for the time being (to avoid unnecessary CPU load).

I am puzzled as to why just leaving 'static compression' enabled causes css files to be returned uncompressed.

My applicationHost.config file has not be altered and looks like this:

        <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
    </httpCompression>

The server-wide compression setting within IIS is set to 'Dynamic Disabled' and 'Static Enabled' from the Server > Features > Compression page.

The web-site compression setting (Server > Sites > MyWebsite > Features > Compression) is where I am enabling and disabling dynamic compression as detailed above.

Any help would be really help me get unstuck on this.

Thanks

share|improve this question
    
Same issue here. –  UpTheCreek May 23 '11 at 17:37

2 Answers 2

Chances are, your CSS file is being served by a dynamic content handler, which means it's considered dynamic content by IIS. If .CSS files are mapped directly to the StaticFileHandler, they'll probably be compressed along with other static content, as long as the mime-type is correct.

To work out whether that's the case:

Turn on Failed Request Tracing for the site, and enable a rule that traces on 200 responses.

Open the failed request log file corresponding with a .CSS request, and check to see which handlers are being invoked to produce the file, and whether compression was regarded as being required. Wildcard script mappings are often the cause of this type of behaviour.

If you don't score more than frequentHitThreshold requests in frequentHitTimePeriod (typically 2 in 120 seconds, if memory serves), the content may not be compressed until breaking that threshold - the same threshold is used for compression as caching.

share|improve this answer

In IIS 6.0, an .aspx page with .css file and Dynamic Compression disabled will compress .css file if you have Static Compression enabled. In IIS 7/7.5, .aspx page with .css file will not compress .css file though we have Static Compression enabled. To compress .css files from the very first request, you will need to enable Dynamic Content Compression in IIS 7/7.5.

Refer the article Changes to compression in IIS7 for better understanding of the behaviour

You can also check my article on the same.

share|improve this answer
1  
I don't think the article says what you're saying it is saying. –  TristanK May 2 '11 at 5:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.