Set up gzip in IIS 8 and Windows 8 - iis

I created the default MCV4 website and hosted in my local IIS8 in widows 8 system under default web site.
http://localhost/MyWesite
in IIS manager "Compression" enabled dynamic content compression and static content compression. also disabled file size limit for compression so all js file sized are considered for compression (still gzip compression did not happen)
Is this the only system level gzip configuration?
Then next I tried to do website level change. I also edited the applicationHost.config file in C:\Windows\System32\inetsrv\config below are the change I did
<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
in the web.config file I added the following
<system.webServer>
<httpCompression>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="image/jpeg" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="image/jpeg" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" />
</httpCompression>
</system.webServer>
After doing this I restarted iis just in case. On loading the webpage no js file or html document got gziped.

Probably you have already fixed this issue, it just happened to me and I found this while looking for the error. I had the exact same web.config configuration (worked perfectly on older webserver with IIS 7.5).
I found that you need to go to Server Manager and make sure that you have setup the Dynamic Content Compression feature, under Web Server => Web Server => Performance.

Related

How to enable compression using IIS

I have followed this document and have enabled both Dynamic and Static compression for my website.
But when I test the website here, the compression is not enabled.
I have verified the HttpCompression:
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="image/svg+xml" 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="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
</httpCompression>
</system.webServer>
I have also checked the following IIS Settings:
I see from your posted headers that the site is behind cloudfront (ie the via and x-cache headers).
Thus you may need to investigate having cloudfront provide compressed data: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html
I'm not particularly familiar with cloudfront, but since its adding the via header its acting as a proxy..
..you have noCompressionForProxies = True in your IIS settings screenshot.
This has some info on changing that setting https://community.spiceworks.com/topic/1989103-help-with-enabling-nocompressionforproxies-in-applicationhost-config-in-iis
As a 1st test you could try to hit your site by-passing cloudfront to directly test the IIS setup.

Gzip not working - NO_MATCHING_SCHEME

Problems with activating Gzip on IIS 8 on a windows server 2012 (standard)
So i activated the compressions in the windows features
I checked both checkboxes in IIS - compression (dynamic and static)
But still no Gzip available. However, on my localhost machine (just a windows 10) this works.
What i do see, is that the gzip temp directory (C:\inetpub\temp\IIS Temporary Compressed Files) is getting filled up when i browse my site via the server localhost. BUT strangely enough i'm not seeing anything Gzip-ped in chrome.
The only headers (in chrome) are: HTTP/1.1 304 Not Modified Accept-Ranges: bytes ETag: "0a354779de8d11:0" Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET Date: Thu, 28 Jul 2016 13:41:04 GMT
(Even yslow is saying no gzip is activated)
When i remove the gzip temp folder, and browse to the site trough the 'official' website url, then nothing is even generated.
Does anyone has any idea what is going on here?
I added this in my web.config
<httpCompression>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="image/jpeg" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="image/jpeg" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" />
</httpCompression>
See this other topic, where i activated more log information, Gzip not working, server 2012, IIS 8
All i get is:
<RenderingInfo Culture="nl-BE">
<Opcode>STATIC_COMPRESSION_NOT_SUCCESS</Opcode>
<Keywords>
<Keyword>Compression</Keyword>
</Keywords>
<freb:Description Data="Reason">NO_MATCHING_SCHEME</freb:Description>
</RenderingInfo>
Can you try adding this to your web.config file ?? I suggest so because it worked for me on IIS windows shared hosting. Its similar to your code with a few changes...
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="application/javascript; charset=utf-8" enabled="true"/>
<add mimeType="application/x-javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="application/javascript; charset=utf-8" enabled="true"/>
<add mimeType="application/x-javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>
I'm not sure if you need to add
<add mimeType="image/jpeg" enabled="true" />
Isn't jpeg a compressed format ? You could add it none the less if you wish to.
[OPTIONAL]: I read this at MaxCdn.
Origin servers should include Vary: Accept-Encoding, and here’s how:
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Vary"></remove>
<add name="Vary" value="Accept-Encoding"></add>
</customHeaders>
</httpProtocol>
</system.webServer>
You can add this bit to your web.config file as well, deploy and check it in the request headers through your browser's developer tools itself.

gzip compression & iis express/iis?

Does anyone know why the following web.conig changes will NOT work:
<httpCompression>
<staticTypes>
<add mimeType="application/javascript" enabled="true"/>
</staticTypes>
<dynamicTypes>
<add mimeType="application/javascript" enabled="true"/>
</dynamicTypes>
</httpCompression>
After i added javascript files were still not being compressed (gzip). I thrased around for a couple days because i really didn't know what the problem was at first but now i do. If i change the applicationhost.config directly though it does work:
<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
It would be MUCH easier to change your web.config then trying to figure out what web servers applicationhost.config file is incorrect but unfortunately it doesn't work
That being said IIS Express is setup "incorrectly" by default. It gives javascript files a mimetype of "application/javascript" but only compresses javascript files that come across as "application/x-javascript". I don't know if IIS (not express) ever comes defaulted this way.
You could try adding the doDynamicCompression attribute with a value of true to the urlCompression attribute.
<urlCompression doDynamicCompression="true" />

Static content compression over Azure Web Role & Azure CDN not working

My website is hosted on an Azure WebRole and the content is fetched using Azure CDN.
The main HTTP request itself is compressed, but the static content (css & js are the main issue here) isn't.
The request is sent with 'Accept-Encoding: gzip,deflate,sdch' header, but the response is missing the 'Content-Encoding: gzip' and 'Vary: Accept-Encoding' headers.
It's important to note that this happens when fetching the content both from and the CDN and directly from the WebRole.
These are the relevant web.config sections:
<urlCompression doDynamicCompression="false" doStaticCompression="true" />
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" noCompressionForHttp10="false" noCompressionForProxies="false">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
As you can see in the config, I've enabled compression for proxies and for HTTP 1.0, but it doesn't seem to be the problem.
Anyone has an idea what's wrong here?

GZip compression in IIS7 not working, but content-encoding header is set to gzip

I have IIS 7.5 with static and dynamic compression enabled. It seems to work fine for dynamic files, but for static ones it behaves erratically, often sending a http header "Content-Encoding: gzip" when the content is not compressed. This causes browsers to attempt to uncompress, throwing an invalid magic number error. Here's my configuration:
<httpCompression dynamicCompressionDisableCpuUsage="95" dynamicCompressionEnableCpuUsage="70" >
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
I thought some http module was uncompressing the content somewhere down the pipe, but none of them seem suspicious. Any ideas?
Try to enable dynamic compression before cache which is disabled by default.
<urlCompression dynamicCompressionBeforeCache="true" doDynamicCompression="true" doStaticCompression="true" />
I have found out in my investigations that using HttpContext.RewritePath() on a static file causes this problem.
Took me a while to figure this out too. Setting the frequentHitThreshold attribute to 1 on the system.webServer/serverRuntime node in the applicationHost.config file should do the trick, as documented at http://www.iis.net/ConfigReference/system.webServer/serverRuntime.
You can do this by executing the following command as an administrator:
%windir%\system32\inetsrv\appcmd set config /section:serverRuntime /frequentHitThreshold:1 /commit:apphost
A word of warning - the "frequent hit" concept does not seem specific to compression. I have no idea whether there are other consequences as a result of setting this!

Resources