Why is gzip compression not working on IIS 8.5? - asp.net

I am unable to get gzip compression working on IIS 8.5 on a Server 2012 R2 machine. I have done some research and followed the instructions found in these posts:
How to enable GZIP compression in IIS 7.5
Compression in IIS 8.5 not successful, stating ALREADY_CONTENT_ENCODING
GZip Compression On IIS 7.5 is not working
gzip compression not working with IIS 8.5
Here is the relevant section of my config:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" staticCompressionIgnoreHitFrequency="true">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<!-- I have read that dynamic compression increases server CPU load.
<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" />
Also, in IIS, I set compression to apply to anything larger than 256 bytes. And I have performed iisreset.
Nonetheless, I don't see the compression mentioned in my dev console in Chrome or IE and PageSpeed still tells me to compress stuff. What simple step have I missed?

It will be difficult to understand what is happening.Assuming that you have done all the IIS settings correct.
For checking if compression is working fine or not,How are you accessing the website. e.g. If you use an FQDN www.example.com ,please try and use localhost url. This will make sure your IIS settings are correct.
If localhost works fine and your Fully Qualified domain name does not work,then problem can be in the network.In order for compression to work,the browser needs to send request header accept-encoding:gzip, deflate . many at times your proxy or load balancer can trim this header and this header may not reach the IIS server.So IIS will never compresseven if all the settings are done right.
To verify what is happening for the request and why IIS did not compress the request,you can do the following.
make sure you have Failed Request tracing installed.
Configure your Failed Request Definition
Go to Failed Request tracing Modules
Click Add on the sidebar
Enable All Content and status as 200-999
And Finish the configuration.
Now reproduce the issue and you will get a traces captured in directory C:\inetpub\logs\FailedReqLogFiles\W3SVC .
Open the trace file(for each requests one file will be generated.Open the trace file in IE(make sure the request details matches the request you would like to verify) and go to the compact view
Search for Compression and also check the reason

As mentioned in answers to one of the questions the OP links to, be sure to check for any anti-virus software running on the server. In my case it was ESET. None of the IIS compression settings had an effect until the relevant ESET settings were disabled.
I'm leaving out details of the settings- I did what seemed like a pretty blanket disable and left it to IT to figure out which exact setting was most appropriate for compression to still work while retaining security.

I had a similar issue and was caused by ESET with some strange behavior.
It worked on some machines but not on the one with eset, it took me some time to realize.
What happened is that ESET caused chrome to downgrade http2 requests to http 1.1 and not compress them. It can be seen if you open network and enable 'protocol' column. After removing eset it worked even if I forced chrome to use http1.1 with '--disable-http2' flag
Anyway if it still not working I would try to (in addition to the other answers):
check if different clients behave the same (in my case only dev machine had the issue)
deploy a simple static site (event default one) and test
reinstall iis
check settings on iss server manager, configuration editor / system.webServer/httpCompression collection, change compression level

Related

My website hosted in the local iis can't load images, js and other files

I am totally new to IIS and this is my first attempt to host one of my websites on my own machine's IIS server.
I installed IIS using Add windows features on or off feature and used aspnet_regiis -i to install asp on it.
Then I copied my website's content to wwwroot directory and I have a partially working website, because some fonts, images, js files and a webm file can't be loaded into the page and when I go to these files by url I get this error message:
HTTP Error 404.3 - Not Found The page you are requesting cannot be
served because of the extension configuration. If the page is a
script, add a handler. If the file should be downloaded, add a MIME
map.
I should mention that I checked static content under common http features in Add windows features on or off but still I have the same problem
Thanks in advance for your help
UPDATE:
I used to have a host and domain and this website worked perfectly there, So it Not a website problem
UPDATE2
some pictures load ok and some don't.some fonts are ok and some don't.chrome's developer console states an 404 error message for missing files and scripts and when I go to them via url,I get the error message above(which indeed is a 404 error message)
UPDATE3
I added woff and webm formats to MIME types so now these types of files work.But still some javascript files won't work since they are using json I json format and json is not added yet to the list of MIME types
What can I do so that ALL TYPES OF FILES are allowed?
Modify your web.config like
<system.webServer>
<staticContent>
...
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
...
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>

Http Error 404:14 - Forbidden

I've installed my web application already in IIS. But when we run it, it contains HTTP Error 403.14 - Forbidden. I've researched about the solutions.
Enabled Directory Browsing.
-But enabling directory browsing is not allowed.
Add Defalut Document
-I already have a default Document.
So now, I'm practically lost on how to solve this issue.
Have you already registered the framework for iis in the computer?
C:\windows\Microsoft.NET\Framework64\v4.0.30319> .\aspnet_regiis.exe -ir C:\windows\Microsoft.NET\Framework64\v4.0.30319> iisreset
run that in command prompt
Note: Path will of course change depending on your local drive
I've already solved this issue. There's just something wrong with my default document in my web.config. I used ~/Login.aspx instead of Login.aspx.
<defaultDocument enabled="true">
<files>
<clear />
<add value="Login.aspx" />
</files>
</defaultDocument>

Possible to add MIME type to web.config without possibly breaking the site?

I had a web.config in one of the websites on my IIS that was adding a support for .7z file extension. When I later added a global .7z support at the server level, this site was broken - IIS Manager is complaining that it "cannot add duplicate collection entry of type 'mimeMap'..." and all web requests to i.g. CSS files ended with an HTTP 500 error.
I was using this in the site's web.config:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />
</staticContent>
</system.webServer>
Is there maybe some other syntax that would add 7z to the list only if it wasn't defined yet?
According to this, you should remove the global setting in the special config before adding it in a different form.
Explcitly:
<system.webServer>
<staticContent>
<remove fileExtension=".7z" />
<mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />
</staticContent>
</system.webServer>
Of course this doesn't really help you now as you might just as well drop the local setting completely (as it's likely to coincide with the global setting). But if you had known this back when you added local 7zip support, you wouldn't have encountered the error now ...

IIS 7.5 error the requested resource can't be accessed

I'm trying to sort out my issue. i give all configuration issue but still getting this error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File \\?\C:\inetpub\wwwroot\WebSetup1\web.config
</modules>
116: <handlers>
117: <remove name="WebServiceHandlerFactory-Integrated" />
I also give access to Allow and in module also but still getting this error
using window 7 with IIS 7.5 + ASP.Net 3.5
any idea?
IIS 7.5 is a bear when it comes to user permissions. I would check that the defaultapppool or whatever your IIS user is for your app has permission to access the directory. Hope this helps.
Try to use in web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<!-- ... -->
</system.webServer>

HttpCompression element in web.config not read in IIS7.5

I'm trying to override the httpCompression element within Web.config for a site on an IIS 7.5 running Windows 7, but it does not seem to be read at all.
To check, I've introduced typeos within the element, but I can't even get a configuration error.
Here is an example of the httpCompression element from Web.config
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<SCHEMEx name="deflate" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="false" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTUPES>
</staticTUPES>
</httpCompression>
When I introduce similar errors in other element (like ie modules) I get a configuration error, so I know the config file is read.
I've unlocked the section in ApplicationHost.config:
appcmd unlock config /section:system.webserver/httpcompression
But that did not work, so I changed ApplicationHost.config manually so it now reads:
...
<section name="httpCompression" overrideModeDefault="Allow" />
...
What I'm really trying to accomplish is to set "deflate" as the only compression scheme for one of my sites.
For this to work, after unlocking the application.config file you have to set the specific configuration via command line as well..
1) Unlock the httpCompression part of the application.config:
C:\Windows\System32\inetsrv\appcmd.exe unlock config /section:system.webServer/httpCompression
2) Lets suppose you want to handle dynamic JSON requests (e.g. mimetype = application/json), you should use this command:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
3) If JSON requests is your case, you might also want to handle the charset=utf-8 variation, which for some reason is what IIS gives you back in most cases:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
I had a slightly similar problem before, too long ago to remember in detail. I think I resorted to making the changes directly to the ApplicationHost.config (%windir%\system32\inetsrv\config), but not an ideal solution.
Assume you've looked here
http://www.iis.net/configreference/system.webserver/httpcompression -
Have you tried using the clear element as mentioned in this post?

Resources