IIS 7.5 gzip compression on shared hosting

I have a website that uses ASP.NET and is hosted on an IIS 7.5 public host, so I don't have direct access to IIS settings. Now I want to enable gzip-compression of my pages and css / js files using IIS features, but none of the recipes found on the Internet worked for me. For example, when I add what is written here to my Web.config, nothing changes: no errors, no compression.

Is it possible? If not, what is the best alternative?

+2
web-config gzip shared-hosting
Aug 24 '11 at 6:41
source share
3 answers

Try a sample configuration at the bottom of this article:

http://www.iis.net/ConfigReference/system.webServer/urlCompression

<configuration> <system.webServer> <urlCompression doStaticCompression="true" doDynamicCompression="false" /> </system.webServer> </configuration> 

This question says that:

"Yes, you can enable compression using web.config, as shown in the next article, but this may depend on server permissions that allow sites."

See if this helps you:

IIS 7.5 ASP.NET-4 Gzip Compression

Or that:

GZip compression in IIS 7.5 does not work

+3
Aug 24 2018-11-11T00:
source share
— -

I ran into the same problem and therefore used .net compression caused by using global.asax, along with renaming static css with the .aspx extension and using url rewriting via Web.config. On top of .css.aspx I just added

 <%@ Page ContentType="text/css" %> 

In the rules for rewriting system.webserver Web.config configuration:

 <rule name="san aspx"> <match url=".*[^/]$" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="{R:0}.aspx" /> </rule> <rule name="revert aspx"> <match url="(.*)\.aspx$"/> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> </conditions> <action type="Rewrite" url="{R:1}" /> </rule> 

In Application_PreRequestHandlerExecute global.asax

 HttpApplication app = sender as HttpApplication; string acceptEncoding = app.Request.Headers["Accept-Encoding"]; Stream prevUncompressedStream = app.Response.Filter; if (acceptEncoding != null && acceptEncoding.Length > 0) { acceptEncoding = acceptEncoding.ToLower(); if (acceptEncoding.Contains("gzip")){ app.Response.Filter = new GZipStream(prevUncompressedStream, CompressionMode.Compress); app.Response.AppendHeader("Content-Encoding", "gzip"); } } Response.Cache.VaryByHeaders["Accept-Encoding"] = true; 

It seems intimidating, but with building the right understanding, it works like a charm and is worth saving on SEO related to PageSpeed, as well as shared hosting. I tried with the support of my hosting provider, but instead they sold more exotic hosting packages. For forcefully compressed content such as a .svgz file, I used a separate folder and the httpProtocol system.webserver of this web.config folder I wrote:

 <customHeaders> <add name="Content-Encoding" value="gzip" /> </customHeaders> 
+4
Jan 24 '13 at 19:17
source share

I know this is super old, but I found this link that really worked for me. I have arvixe hosting and they also do not allow compression. I tried everything in web.config which did not work, but it is in global work

http://forums.asp.net/t/1599397.aspx?Best+Way+to+Enable+HTTP+Compression

0
Jul 18 '14 at 2:40
source share



All Articles