First, we need to download DC.Web.HttpCompress.dll and reference it to our ASP.net project. Next in the web.config simple configuration, you can achieve gzip compression, need to configure the place as follows:
| The code is as follows |
Copy Code |
|
<sectiongroup name= "Dcweb" >
<section name= "httpcompress" type= DC. WEB.HTTPCOMPRESS.CONFIGURATION,DC. Web.httpcompress "/>
</sectionGroup>
</configSections> |
<!--Configure gzip compression-->
| The code is as follows |
Copy Code |
|
<DCWeb>
<!--set Jspath and Csspath, the default value is used if you delete this row configuration-->
<pathsettings jspath= "javascript" csspath= "CSS"/>
<IncludedMimeTypes>
<add mime= "text/html"/>
<add mime= "Image/gif"/>
<add mime= "Image/jpeg"/>
<add mime= "Text/css"/>
<add mime= "Application/x-javascript"/>
</IncludedMimeTypes>
<!--configure which types of resources are not compressed use:
<ExcludedMimeTypes>
<add mime= "text/html"/>
</ExcludedMimeTypes>
Note: Excludedmimetypes and includedmimetypes only need to configure one, and if Excludemimetypes is configured like the above, it means that other resources will be compressed except HTML-type resources-->
<!--<ExcludedPaths>
Set the page path that does not enable compression, the following sets the Default.aspx page in the Nocompress directory will not enable compression, but other pages normally enable compression
<add path= "~/nocompress/default.aspx"/>
</ExcludedPaths>-->
</HttpCompress>
</DCWeb>
<add name= "Httpcompressmodule" type= DC. WEB.HTTPCOMPRESS.HTTPMODULE,DC. Web.httpcompress "/> |
Here we have achieved asp.net gzip compression, below look at my local test results, you can use Google Chrome browser to see whether to enable gzip compression, use CTRL+SHIFT+J to open, click Resources to view files,
In addition to the above methods we can also use IIS to open gzip compression, here I do not introduce you can go to the station's Windows Server channel to find.