IIS 7 HttpCompression Not Working - iis-7

I am using following web.config block to enable static and Dynamic Compression on IIS7, but its not compressing the response.(Verified it through Fiddler)
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/css" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/css" enabled="true" />
<add mimeType="text/javascript" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="true" />
</staticTypes>
</httpCompression>
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/x-javascript" />
</staticContent>
Yet it is not doing any compression. I had also check the server has static/dynamic compression installed.also tried this how-can-i-get-gzip-compression-in-iis7-working but not working for me. Can anyone help with something new?

I had trouble with getting it working by following snippets of advice on StackOverflow. Here's how I managed it.
First, ensure Dynamic Compression is installed as a feature of the Web Role. Normally, you get a warning in IIS Manager if the module is not installed, but you won't if you've set the web.config manually since it tricks the IIS UI logic.
I then removed all the web.config stuff (as in your question) and set it via the IIS Manager. I did this because on MSDN, an easily-missed comment says:
You can also add wildcard entries for the MIME types. However, you can
set MIME types for the web server level only. For example, to enable
static compression for all MIME types for the default website, first
add wildcard entries for the MIME types for the server level, and then
enable static compression for the default website.
Focus on:
However, you can set MIME types for the web server level only.
So I'm not sure whether all those filters and things really work in the web.config. Personally, it didn't for me - i.e. no Content-Encoding: gzip header.
After I took it all out I had to use IIS Manager, under IIS: Compression, to ensure it was set at the server level and then for the site, I had to remove the tick, apply it, tick it again and reapply it.
I ended up with just <urlCompression doDynamicCompression="true" /> in the web.config, which is a bit strange since I don't care for compressing URLs.
Whatever. I do now have Content-Encoding: gzip in the response headers for my site - so I assume its working.

Could you enable Failed Request Tracing, it should include information about what could be happening, it usually falls into a few buckets, 1) Permissions to generate the compressed file, 2) File is too small to require compression, 3) File is not being frequently enough so it is not being compressed, 4) mimetype issue
http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis7/

Related

Enable gzip compression using MVC3

I am using the chrome extension YSlow to test my site performance.
I've got F Grade on Compress components with gzip.
There are 15 plain text components that should be sent compressed:
http://localhost:21964/Content/custom/css/blog.css
http://localhost:21964/Content/custom/css/style.css
http://localhost:21964/Content/custom/css/socialize-bookmarks.css
http://localhost:21964/Content/custom/css/prettyPhoto.css
http://localhost:21964/Content/custom/css/flexslider.css
http://localhost:21964/Content/custom/css/colors/color-orange.css
http://localhost:21964/Content/sc2.css
http://localhost:21964/Content/custom/javascript/custom.js
http://localhost:21964/Content/custom/javascript/header.js
http://localhost:21964/Content/custom/javascript/twitter.js
http://localhost:21964/Content/custom/javascript/bra.photostream.js
http://localhost:21964/Content/custom/javascript/jquery.flexslider.js
http://localhost:21964/Content/custom/javascript/jquery.bpopup-0.7.0.min.js
http://localhost:21964/Content/custom/javascript/prettyPhoto.js
http://localhost:21964/css/colors/color-orange.css
Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.
There was a similar post here, But even though I've followed these steps it doesn't compress the traffic.
Steps I've done:
I ticked all the compression settings in the IIS -> Compression.
Activate the Windows Feature "Dynamic Content Compression".
I've added this lines to the web.config:
<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="*/*" enabled="true"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="true"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
...
</system.webServer>
I am currently using the Developer Server inside the project Properties -> Web -> Servers
The visual studio development server (Cassini) doesn't support gzip compression use IIS or IIS Express.

httpCompression directory on IIS 7 for multiple websites

Scenario:
At our company, we have enabled httpCompression for our website. This website (call it as master website) and its preview version both are hosted on the same web server. Preview version is used for testing.
The compression settings in the web.config file are
<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>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true"/>
According to this article, compressed files are temporarily saved/cached to the directory specified in the config settings. In my case, it's %SystemDrive%\inetpub\temp\IIS Temporary Compressed Files.
I do not have access to the web server to look at those compressed files. so here are my questions.
How the compressed files are saved/cached or named for different web sites?
Let's say I use same compression directory for both web sites (preview and master). If a user requests a static file from preview website, it is compressed and cached in the directory. Now, another user requests the same file but from master web site. Does the server sends the compressed file of the preview website or it compresses the file again and saves to the directory?
IIS Creates a complex directory structure such as follows:
%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files\(compressionType)\(AppPool)\(WebSite)\compressed files
It will not share the compressed version of the same files across web applications.
So to answer your question, there will be 2 compression versions of the file.
PS - You could have also turned on compression locally on IIS 7.5 and saw this structure locally.

Will adding gZip compression to my web app improve the performance of loading of large images?

I have a web app that contains a slide show with about 10 large images (100-200k) images. I've heard of people using gZip http compression to help improve the performance of their websites in the past so I started doing a little research on this. I ended up finding the following web.config snipit that claims to do this:
<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="*/*" 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>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>
But after looking at it a little closer this does not appear to do anything for images.
Is using gZip compression for image mimeTypes effective or would I be wasting my time to add it to the above? Can anyone recommend any good strategies for improving the load time of large images?
Side note: Not sure if it makes a difference but the site is hosted on goDaddy.
JPG images, GIF, etc are already compressed formats. Compressing them further isn't going to help much. You should be looking into caching them instead so that the web server returns 304 responses every time a request for the same image is made.
By the way, the Web.config that you posted is not doing compression on images (as it doesn't help).
UPDATE
Configure IIS to return HTTP 304 Status codes on certain file types.
The JPEG format is a compressed format. So no need to compress it again. Think about compressing scripts and css.
Use SquishIt for compressing javascript and CSS.
Try SmushIt from Yahoo to optimise the images

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.

iis7 compress dynamic content from custom handler

I am having trouble getting dynamic content coming from a custom handler to be compressed by IIS 7.
Our handler spits out json data (Content-Type: application/json; charset=utf-8) and responds to url that looks like: domain.com/example.mal/OperationName?Param1=Val1&Param2=Val2
In IIS 6, all we had to do was put the edit the MetaBase.xml and in the IIsCompressionScheme element make sure that the HcScriptFileExtensions attribute had the custom extension 'mal' included in it.
Static and Dynamic compression is turned out at the server and website level.
I can confirm that normal .aspx pages are compressed correctly.
The only content I cannot have compressed is the content coming from the custom handler.
I have tried the following configs with no success:
<handlers>
<add name="MyJsonService" verb="GET,POST" path="*.mal" type="Library.Web.HttpHandlers.MyJsonServiceHandlerFactory, Library.Web" />
</handlers>
<httpCompression>
<dynamicTypes>
<add mimeType="application/json" enabled="true" />
</dynamicTypes>
</httpCompression>
_
<httpCompression>
<dynamicTypes>
<add mimeType="application/*" enabled="true" />
</dynamicTypes>
</httpCompression>
_
<staticContent>
<mimeMap fileExtension=".mal" mimeType="application/json" />
</staticContent>
<httpCompression>
<dynamicTypes>
<add mimeType="application/*" enabled="true" />
</dynamicTypes>
</httpCompression>
Thanks in advance for the help.
looks like it is a bug in the IIS compression.
I needed to add the following line to the applicationHost.config file (under httpCompression ) instead of the web.config
<dynamicTypes>
<add mimeType="application/json; charset=utf-8" enabled="true" />
</dynamicTypes>
found some extra help from here: http://forums.iis.net/p/1162828/1925766.aspx

Resources