Enable compression fontawesome-webfont.svg - asp.net

I am always getting RED mark "enable compression for fontawesome-webfont.svg"
on https://developers.google.com/speed/pagespeed/insights/
Compressing resources with gzip or deflate can reduce the number of bytes sent over the network.
Enable compression for the following resources to reduce their transfer size by 175KiB (70% reduction).
Compressing /fonts/fontawesome-webfont.svg?v=4.0.3 could save 175KiB (70% reduction).
I already did IIS provided compression options:
Static files only
Dynamic application responses only
Both static files and dynamic application responses

By default, IIS doesn't map the MIME type for SVGs. You will have to update your Web.config to include the correct mappings for SVGs like so:
<system.webServer>
<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/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
<!-- HERE -->
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="application/font-woff" enabled="true" />
<add mimeType="application/x-font-ttf" enabled="true" />
<add mimeType="application/octet-stream" enabled="true" />
<!-- HERE -->
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>
For more details on this, check out this answer. To test whether compression is working or not, use the Chrome Developer Tools and check the HTTP response header contains the following:
Content-Encoding: gzip

Related

IIS express and IIS7 path

I expert,
I need to update some dll on a web program running in IIS7. I prepare all the work on my PC in Visual Studio and IIS express, all change is working well. So I do a local file system deploy and copy the content to the production server running IIS7.
Some fonts, glyphs are not display correctly. In the network tab I can see that all the file that does not load have a 301 permanent redirect and then 404 not found. I double-check the server directory the files are present.
The only thing I can see is the path is not the same. for example, on IIS Express:
http://localhost:49193/Content/kendo/fonts/glyphs/WebComponentsIcons.ttf?gedxeo
Then on the production site
http://ProductionSite.com/Content/fonts/glyphs/WebComponentsIcons.ttf?gedxeo
the source for the file is in the css like this: src:url(fonts/glyphs/WebComponentsIcons.eot?gedxeo)
Any idea?
UPDATE1
Mime definition:
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<!-- Compress XML files -->
<add mimeType="application/xml" enabled="true" />
<!-- Compress JavaScript files -->
<add mimeType="application/javascript" enabled="true" />
<!-- Compress JSON files -->
<add mimeType="application/json" enabled="true" />
<!-- Compress SVG files -->
<add mimeType="image/svg+xml" enabled="true" />
<!-- Compress RSS feeds -->
<add mimeType="application/rss+xml" enabled="true" />
<!-- Compress Atom feeds -->
<add mimeType="application/atom+xml" 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/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<!-- Compress ICO icon files (Note that most .ico files are uncompressed but there are some that can contain PNG compressed images. If you are doing this, remove this line). -->
<add mimeType="image/x-icon" enabled="true" />
<!-- Compress XML files -->
<add mimeType="application/xml" enabled="true" />
<add mimeType="application/xml; charset=UTF-8" enabled="true" />
<!-- Compress JavaScript files -->
<add mimeType="application/javascript" enabled="true" />
<!-- Compress JSON files -->
<add mimeType="application/json" enabled="true" />
<!-- Compress SVG files -->
<add mimeType="image/svg+xml" enabled="true" />
<!-- Compress EOT font files -->
<add mimeType="application/vnd.ms-fontobject" enabled="true" />
<!-- Compress TTF font files - application/font-ttf will probably be the new correct MIME type. IIS still uses application/x-font-ttf. -->
<!--<add mimeType="application/font-ttf" enabled="true" />-->
<add mimeType="application/x-font-ttf" enabled="true" />
<!-- Compress OTF font files - application/font-opentype will probably be the new correct MIME type. IIS still uses font/otf. -->
<!--<add mimeType="application/font-opentype" enabled="true" />-->
<add mimeType="font/otf" enabled="true" />
<!-- Compress RSS feeds -->
<add mimeType="application/rss+xml" enabled="true" />
<add mimeType="application/rss+xml; charset=UTF-8" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
c
Check for Mime Type. May mime type is not added for fonts on production server.
I don't understand why. My client use an very old IIS 7.5 server...
For now the only way to solve my problem is to add:
BundleTable.EnableOptimizations = false
into the bundle.config file.

IIS Compression setting for batch request mime type 'multipart/mixed'

I have a web api service that accepts batch requests from a web app. I have defined the mime type 'multipart/*' to be compressed in the web.config but the response is not compressed. I'm not sure why it is not working as normal single requests (not sent as a multipart/mixed are compressed fine).
<httpCompression>
<dynamicTypes>
<clear />
<add enabled="true" mimeType="text/*" />
<add enabled="true" mimeType="application/javascript" />
<add enabled="true" mimeType="application/json" />
<add enabled="true" mimeType="multipart/*" />
<add enabled="false" mimeType="*/*" />
</dynamicTypes>
<staticTypes>
<clear />
<add enabled="true" mimeType="text/*" />
<add enabled="true" mimeType="application/javascript" />
<add enabled="true" mimeType="application/json" />
<add enabled="true" mimeType="multipart/*" />
<add enabled="false" mimeType="*/*" />
</staticTypes>
</httpCompression>
The actual response mime type starts with 'multipart/mixed' but varies depending on the boundary id appended to it.
Content-Type:multipart/mixed; boundary="0bb00cbc-234a-4264-87dc-60109719e79f"
The request is sending up an Accepted-Encoding header so I don't think the problem is there I think it is something to do with IIS match the mime type.
Any ideas would be awesome!
Thanks,
Jon
I also ran into this, and was able to get around this by using this NuGet package:
https://www.nuget.org/packages/Microsoft.AspNet.WebApi.MessageHandlers.Compression/
This also supports the compression of the batch responses.
Info on how to use it is on the github page:
https://github.com/azzlack/Microsoft.AspNet.WebApi.MessageHandlers.Compression

Compression in WebApi hosted on Azure

My Web Api is hosted on AzureWebsites and exposed through Azure Api management. I just wondering how the compression will be enabled in such scenario? Will it be something on azurewebsites or it should be done through Api management portal and HOW?
This should enable gzip on every IIS-compatible host:
<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="application/*" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="application/*" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>

Configuring IIS dynamic compression of Json

I'm having problems testing the dynamicCompression of my Json output. The Application is an MVC/WEBAPI5 application and the request I'm investigating is a Get WebAPI request.
Im getting Json back but its not being compressed.
I've followed the steps to configure dynamic compression of Json in IIS8 in How can I get gzip compression in IIS7 working?
as :
<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/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" 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/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
I have the compression module installed and i can see the following in the FailedRequestTracelog for this particular call:
You can see in my fiddler trace that it does seem to be a matching type despite it saying this is not the case in the FailedRequestTrace output.
Any ideas?
You can take a look at my below blog post on one way of doing compression in Web API.
http://blogs.msdn.com/b/kiranchalla/archive/2012/09/04/handling-compression-accept-encoding-sample.aspx
If you would like to use IIS for compression, take a look at the following post:
https://stackoverflow.com/a/17331627/1184056

Gzip http compression problem on iis7

My web hosting provider is running IIS7 and I am having loads of trouble to get gzip compression to work properly. Host admins say compression is installed. I can confirm compression using some online checking services but not with others. PageSpeed Firefox add-on also says the site is uncompressed. I am personally sitting behind a Squid proxy but web.config settings should take care of proxy issue. Below is the relevant web.config snippet. Most of it is borrowed from various sites. Any thoughts?
<urlCompression doDynamicCompression="true" dynamicCompressionBeforeCache="true" doStaticCompression="true" />
<httpCompression cacheControlHeader="max-age=86400" noCompressionForHttp10="False" noCompressionForProxies="False" sendCacheHeaders="True" dynamicCompressionEnableCpuUsage="89" dynamicCompressionDisableCpuUsage="90" minFileSizeForComp="1" noCompressionForRange="False">
<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>
This post is about 4 months old, but have you checked if dynamic compression is enabled in IIS? There's an article here on how to do it
http://blog.wassupy.com/2009/08/enabling-dynamic-http-compression-in.html
By default IIS it isn't enabled. Might be worth trying.
Try two this towards resolving this issue:
Try following the case standard for setting booleans in the web.config and use lower case rather than pascal casing.
Try connecting to the site on the server via IIS if your host allows this and check the compression section to see if it is locked.

Resources