IIS6.0 Open gzip method and PHP gzip function sharing _php Tutorial

Source: Internet
Author: User
Tags metabase
GZIP Compression for IIS

1. First back up the IIS configuration file and copy the C:\Windows\system32\inetsrv\metabase.xml to a different backup folder. C:\Windows\system32\inetsrv\metabase.xml is the core configuration file for IIS, and the integrity of the file is destroyed, and IIS will not function properly, severely to the need to reinstall the system.

2. Start the Internet Information Services (IIS) Manager in the Start menu, right-click on the "Web site" property, open the "Services" tab and tick the two options for "HTTP compression". The "Temp directory" and "temporary directory maximum capacity" can be set on their own. Click OK when the settings are complete.

3. Right click on "Web service Extension" under "website", add a new Web service extension, fill in the extension as "HTTP Compression" or other, all can. "Required Files" add: C:\windows\system32\inetsrv\gzip.dll, and tick "set extension status to allow" and click OK when done.

4. The following steps are somewhat complex, if there is no certainty to understand, it is best not to try, right click on the "Internet Information Services" "Local Computer" property, check "Allow direct editing of the configuration database" and determine.

5. Run Notepad C:\Windows\system32\inetsrv\metabase.xml in the Start menu, open the MetaBase.xml file, and confirm that the file has been backed up before any changes.

6. Open MetaBase.xml with a text editor, find "IIsCompressionScheme" with find function, a total of 3, all together, respectively deflate, Gzip and parameters,deflate is also a compression format, However, performance is not as good as gzip. Need to modify the deflate and gzip two paragraphs, the parameters are basically the same, you have to modify.

The hcdynamiccompressionlevel is used to set the compression rate, which defaults to 0, up to 10. A lower compression level produces slightly larger compressed files, but has less overall impact on CPU and memory resources. A high compression level typically produces smaller compressed files, but consumes more CPU time and memory. Some say setting it to 9 is the most cost-effective.

HcFileExtensions is used to set the compression of the static file extension, the default is HTM, HTML, txt, according to the site's own situation to add extensions, the most basic is JS, CSS. Note the original line wrapping format when adding.

HcScriptFileExtensions is used to set the compression of the dynamic file extension, the default is ASP, DLL and EXE, according to the need to add their own extension, no outside of ASPX, PHP and so on. You can leave the default deletion of this item blank so that all dynamic responses are sent in a compressed manner. In addition, all static file types that are not specified in the hcfileextensions are dynamically compressed, and therefore are not put into the cache. Similarly, the hcdodynamiccompression must be set to true for dynamic compression.

PHP Gzip

Copy the Code code as follows:
/*
* Compress data
*/
public static function Ob_gzip ($content)//$content is the content of the page to be compressed, or the biscuit material
{
if (!headers_sent () &&//If the page header information is not output
extension_loaded ("zlib") &&//and zlib extension has been loaded into PHP
Strstr ($_server["http_accept_encoding"], "gzip")//and the browser says it can accept the gzip page
{
$content = Gzencode ($content. " OK ", 9); This page has been compressed "comment label, and then use the Gzencode () function provided by zlib to perform a level 9 compression, the parameter value range is 0-9,0 means no compression, 9 is the maximum compression, of course, the higher the compression the more CPU.

Then use the header () function to send some header information to the browser, telling the browser that the page has been compressed with gzip!
Header ("Content-encoding:gzip");
Header ("vary:accept-encoding");
Header ("Content-length:". strlen ($content));
}
return $content; Return the compressed content, or send the compressed cookie back to the workbench.
}

http://www.bkjia.com/PHPjc/780720.html www.bkjia.com true http://www.bkjia.com/PHPjc/780720.html techarticle GZIP compression for IIS 1. First back up the IIS configuration file and copy the C:\Windows\system32\inetsrv\metabase.xml to a different backup folder. C:\Windows\system32\inetsrv\metabase.xml is ...

  • 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.