compressing json response from asp.net server in a shared hosting environment - asp.net

My hosting server is godaddy on a shared hosting environment.
Because of shared hosting environment I do not have access to IIS settings.
For many purposes I send json response to ajax request
I have set the following in my web.config file
<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/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/json" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
I can make my .aspx pages gziped but It is not compressing json responses.
How can I compress json responses..??

I think the answer is that you need your own VPS server (if you are on a budget) or your own dedicated server. Then you can modify the applicationHost.config for IIS7

Related

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

compress my asp pages with gzip

trying to compress my asp pages, done this but nothing, what can i do?
<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"/>
Step 1: Enable compression as described on microsoft web site. See link from 12/Dec/2013.
Step 2: Make sure that direct metabase edit is enabled.
Step 3: Stop all IIS related services, and make changes in file \system32\inetsrv\metabase.xml:
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="css
txt
gif
png
js
htm
html"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="css
txt
gif
png
js
htm
html"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>

gzip not working in iis7.5 [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I get gzip compression in IIS7 working?
I have enabled static compression on iis7.5 but my .js and .css files are not getting compressed.
my web.config
<staticContent><remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
</staticContent><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"/>
Still YSlow Grad: F. Any ideas?
change this line:
<add mimeType="application/javascript" enabled="true"/>
to:
<add mimeType="text/javascript" enabled="true"/>
for both entries (under dynamictypes and static types).

Adding various filetypes to my IIS7 GZip compression

I have enabled GZip compression via web.config with many helps from another question: Enable IIS7 gzip
I have tested the compression with Live HTTP Headers plugin in FF, and it correctly shows
Content-Encoding: gzip
I have added the following code to my 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="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 is it correct that this code only compress the javascripts and not the CSS, Images and ASP documents?
Apparently I'm just not that bright... It does zip everything after all ;)

Resources