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" />
Related
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.
The sample configuration listed in Microsoft's documentation of the IIS system.webServer/httpCompression configuration setting is as follows:
<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="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
What I'm not understanding is why their list of dynamic and static types are identical. Wouldn't you want a given MIME type to be deterministically registered as either dynamic or static, not both?
In the above example, I can't tell if application/javascript responses will be treated as dynamic or static because it's listed under both settings. Can someone shed some light on how this works?
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.
We are having intermittent issues with SVG rendering after moving our website to Azure Web Sites.
All our svgs appears to load correctly the first time and then on refresh it returns a blank document which then makes chrome give you a error on line 1 at column 1: Encoding error error. If you view source all it shows random characters being returned by the server for example !$. Firefox returns XML Parsing Error: not well-formed
Hard refreshing doesn't work, but leaving it a while will make it work for one time again before it does the same thing again.
I've added in the web.config
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
As suggested by other posts, but no luck.
I fixed this by setting doStaticCompression="false"
<urlCompression doStaticCompression="false" doDynamicCompression="true" />
The above fixed my issue no other settings, but for the sake of completeness, here is the rest of my settings.
I also have
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
And
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<remove mimeType="*/*" />
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/javascript; charset=utf-8" enabled="true" />
<add mimeType="application/octet-stream" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
<remove mimeType="*/*" />
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/javascript; charset=utf-8" enabled="true" />
<add mimeType="application/octet-stream" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
</httpCompression>
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!