asp.net gzip compression Enabling method detailed

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.