Enable gzip compression for websites

Source: Internet
Author: User
Tags metabase

Using gzip to compress page files not only reduces site traffic, reduces server load, but also increases the speed at which users open pages.

1. can be set in the IIS server, unfortunately there is no file extension like http://shenzhen.yekua.cn/fangwuchuzu/ after the URL is rewritten

Unable to enable gzip Compression

2. In Asp.netProgramCan be set in the base class

Public class basepage: system. Web. UI. Page
{
Public basepage ()
{
If (httpcontext. Current. Request. headers ["Accept-encoding"]. tolower (). indexof ("gzip ")! =-1)
{
Httpcontext. Current. response. Filter = new gzipstream (httpcontext. Current. response. filter, compressionmode. Compress );
Httpcontext. Current. response. appendheader ("content-encoding", "gzip"); // If the browser is not set to garbled
}

}

}

3.Iis6.0EnableGzip Compression

① Open website properties in IIS, switch to the "service" tab, and select "compress Application Files" and "compress static files ":

② Right-click "Web Service extension" and choose "Add a new Web Service extension". The settings are as follows:

③ Run "iisreset/restart" in the command line to restart the IIS service;

Configure the file type for gzip Compression

① Run "iisreset/stop" on the command line to stop the IIS service (metabase. XML is read-only when it is enabled );
② Open c: \ windows \ system32 \ inetsrv \ metabase. xml and find:

Reference content <iiscompressionscheme location = "/lm/w3svc/filters/compression/gzip"
Hccompressiondll = "% WINDIR % \ system32 \ inetsrv \ gzip. dll"
Hccreateflags = "1"
Hcdodynamiccompression = "true"
Hcdoondemandcompression = "true"
Hcdostaticcompression = "true"
Hcdynamiccompressionlevel = "0"
Hcfileextensions = "htm
Html
TXT"
Hcondemandcomplevel = "10"
Hcpriority = "1"
Hcscriptfileextensions = "ASP
DLL
EXE"
>
</Iiscompressionscheme>


The hcfileextensions attribute is the static file extension to enable gzip compression, and the hcscriptfileextensions attribute is the dynamic file extension to enable gzip compression, which can be set and saved as needed;
③ Run "iisreset/start" on the command line to enable the IIS service;

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.