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).
Related
I developed a website with Asp.net Website project, and recently I added some https protocol on it. my problem is that the website shows that it is saving cookies, while I really do not like to save any cookies from my users.
I am not familiar with cookies very much but I am sure I did not put any code to save user cookies, how I can be sure If there would not be any cookies for my users and delete any settings for this and why this happening automatically?
my project is a very simple single page website with no form and authentication
here is my web.config if needed.
<?xml version="1.0"?>
<configuration>
<system.web>
<httpRuntime enableVersionHeader="false" targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5"/>
<customErrors mode="On" />
<sessionState mode="Off" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files\(compressionType)\(AppPool)\(WebSite)\compressed files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-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/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true"/>
</system.webServer>
</configuration>
Appreciate very much
ASP.Net has by default session state (https://msdn.microsoft.com/en-us/library/ms178581.aspx) turned on, which in turn relies on cookies by default. If you don't need session state (because users don't logon etc) you can turn it off in the web.config file. Just add
<sessionState mode="Off">
under the
<system.web>
element.
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>
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
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
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 ;)